Fix recursion in crmInArray()
[civicrm-core.git] / bin / cli.class.php
index 195792554074fd8994f34c275613579a1ecc05c0..8cdcc9e8e7c101e1b0fe151881a0b3e7ebaf2f01 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.7                                                |
+ | CiviCRM version 5                                                  |
  +--------------------------------------------------------------------+
  | Copyright Tech To The People http:tttp.eu (c) 2008                 |
  +--------------------------------------------------------------------+
  */
 class civicrm_cli {
   // required values that must be passed
-  // via the command line
-  var $_required_arguments = array('action', 'entity');
-  var $_additional_arguments = array();
-  var $_entity = NULL;
-  var $_action = NULL;
-  var $_output = FALSE;
-  var $_joblog = FALSE;
-  var $_semicolon = FALSE;
-  var $_config;
-
-  // optional arguments
-  var $_site = 'localhost';
-  var $_user = NULL;
-  var $_password = NULL;
+  /**
+   * via the command line
+   * @var array
+   */
+  public $_required_arguments = array('action', 'entity');
+  public $_additional_arguments = array();
+  public $_entity = NULL;
+  public $_action = NULL;
+  public $_output = FALSE;
+  public $_joblog = FALSE;
+  public $_semicolon = FALSE;
+  public $_config;
+
+  /**
+   * optional arguments
+   * @var string
+   */
+  public $_site = 'localhost';
+  public $_user = NULL;
+  public $_password = NULL;
 
   // all other arguments populate the parameters
-  // array that is passed to civicrm_api
-  var $_params = array('version' => 3);
+  /**
+   * array that is passed to civicrm_api
+   * @var array
+   */
+  public $_params = array('version' => 3);
 
-  var $_errors = array();
+  public $_errors = array();
 
   /**
    * @return bool
@@ -99,6 +108,7 @@ class civicrm_cli {
   public function callApi() {
     require_once 'api/api.php';
 
+    CRM_Core_Config::setPermitCacheFlushMode(FALSE);
     //  CRM-9822 -'execute' action always goes thru Job api and always writes to log
     if ($this->_action != 'execute' && $this->_joblog) {
       require_once 'CRM/Core/JobManager.php';
@@ -111,6 +121,8 @@ class civicrm_cli {
       $this->_params['auth'] = FALSE;
       $result = civicrm_api($this->_entity, $this->_action, $this->_params);
     }
+    CRM_Core_Config::setPermitCacheFlushMode(TRUE);
+    CRM_Contact_BAO_Contact_Utils::clearContactCaches();
 
     if (!empty($result['is_error'])) {
       $this->_log($result['error_message']);
@@ -134,7 +146,7 @@ class civicrm_cli {
     // of this script
     array_shift($args);
 
-    while (list($k, $arg) = each($args)) {
+    foreach ($args as $k => $arg) {
       // sanitize all user input
       $arg = $this->_sanitize($arg);
 
@@ -337,7 +349,7 @@ class civicrm_cli {
  * the database in a csv file format.
  */
 class civicrm_cli_csv_exporter extends civicrm_cli {
-  var $separator = ',';
+  public $separator = ',';
 
   /**
    */
@@ -388,8 +400,8 @@ class civicrm_cli_csv_exporter extends civicrm_cli {
  * passed to the script.
  */
 class civicrm_cli_csv_file extends civicrm_cli {
-  var $header;
-  var $separator = ',';
+  public $header;
+  public $separator = ',';
 
   /**
    */
@@ -438,6 +450,7 @@ class civicrm_cli_csv_file extends civicrm_cli {
   }
 
   /* return a params as expected */
+
   /**
    * @param $data
    *
@@ -465,6 +478,7 @@ class civicrm_cli_csv_file extends civicrm_cli {
  *
  */
 class civicrm_cli_csv_importer extends civicrm_cli_csv_file {
+
   /**
    * @param array $params
    */
@@ -486,6 +500,7 @@ class civicrm_cli_csv_importer extends civicrm_cli_csv_file {
  *
  */
 class civicrm_cli_csv_deleter extends civicrm_cli_csv_file {
+
   /**
    * @param array $params
    */