public $userPermissionClass;
/**
- * The root directory where Smarty should store compiled files
+ * The root directory where Smarty should store compiled files.
*
* @var string
*/
}
/**
- * Initialize the DataObject framework
+ * Initialize the DataObject framework.
*
* @return void
*/
}
/**
- * Returns the singleton logger for the application
+ * Returns the singleton logger for the application.
*
* @param
*
}
/**
- * Initialize the config variables
+ * Initialize the config variables.
*
* @return void
*/
}
/**
- * Retrieve a mailer to send any mail from the application
+ * Retrieve a mailer to send any mail from the application.
*
* @param bool $persist
* Open a persistent smtp connection, should speed up mailings.
}
/**
- * Create a new instance of a PEAR Mail driver
+ * Create a new instance of a PEAR Mail driver.
*
* @param string $driver
* 'CRM_Mailing_BAO_Spool' or a name suitable for Mail::factory().
}
/**
- * Deletes the web server writable directories
+ * Deletes the web server writable directories.
*
* @param int $value
* 1: clean templates_c, 2: clean upload, 3: clean both
}
/**
- * Verify that the needed parameters are not null in the config
+ * Verify that the needed parameters are not null in the config.
*
* @param CRM_Core_Config $config (reference) the system config object
* @param array $required (reference) the parameters that need a value
}
/**
- * Reset the serialized array and recompute
+ * Reset the serialized array and recompute.
* use with care
*/
public function reset() {
}
/**
- * This method should initialize auth sources
+ * This method should initialize auth sources.
*/
public function initAuthSrc() {
$session = CRM_Core_Session::singleton();
}
/**
- * One function to get domain ID
+ * One function to get domain ID.
*/
public static function domainID($domainID = NULL, $reset = FALSE) {
static $domain;
}
/**
- * Flush information about loaded modules
+ * Flush information about loaded modules.
*/
public function clearModuleList() {
CRM_Extension_System::singleton()->getCache()->flush();
}
/**
- * Clear db cache
+ * Clear db cache.
*/
public static function clearDBCache() {
$queries = array(
}
/**
- * Clear leftover temporary tables
+ * Clear leftover temporary tables.
+ *
+ * This is called on upgrade, during tests and site move, from the cron and via clear caches in the UI.
+ *
+ * Currently the UI clear caches does not pass a time interval - which may need review as it does risk
+ * ripping the tables out from underneath a current action. This was considered but
+ * out-of-scope for CRM-16167
+ *
+ * @param string|bool $timeInterval
+ * Optional time interval for mysql date function.g '2 day'. This can be used to prevent
+ * tables created recently from being deleted.
*/
- public static function clearTempTables() {
- // CRM-5645
- $dao = CRM_Core_DAO::executeQuery("SELECT DATABASE();");
+ public static function clearTempTables($timeInterval = FALSE) {
+
+ $dao = new CRM_Core_DAO();
$query = "
-SELECT TABLE_NAME as tableName
-FROM INFORMATION_SCHEMA.TABLES
-WHERE TABLE_SCHEMA = %1
-AND
- ( TABLE_NAME LIKE 'civicrm_import_job_%'
- OR TABLE_NAME LIKE 'civicrm_export_temp%'
- OR TABLE_NAME LIKE 'civicrm_task_action_temp%'
- OR TABLE_NAME LIKE 'civicrm_report_temp%'
- )
-";
-
- $params = array(1 => array($dao->database(), 'String'));
- $tableDAO = CRM_Core_DAO::executeQuery($query, $params);
+ SELECT TABLE_NAME as tableName
+ FROM INFORMATION_SCHEMA.TABLES
+ WHERE TABLE_SCHEMA = %1
+ AND (
+ TABLE_NAME LIKE 'civicrm_import_job_%'
+ OR TABLE_NAME LIKE 'civicrm_export_temp%'
+ OR TABLE_NAME LIKE 'civicrm_task_action_temp%'
+ OR TABLE_NAME LIKE 'civicrm_report_temp%'
+ )
+ ";
+ if ($timeInterval) {
+ $query .= " AND CREATE_TIME < DATE_SUB(NOW(), INTERVAL {$timeInterval})";
+ }
+
+ $tableDAO = CRM_Core_DAO::executeQuery($query, array(1 => array($dao->database(), 'String')));
$tables = array();
while ($tableDAO->fetch()) {
$tables[] = $tableDAO->tableName;
}
/**
- * Check if running in upgrade mode
+ * Check if running in upgrade mode.
*/
public static function isUpgradeMode($path = NULL) {
if (defined('CIVICRM_UPGRADE_ACTIVE')) {
}
/**
- * Wrapper function to allow unit tests to switch user framework on the fly
+ * Wrapper function to allow unit tests to switch user framework on the fly.
*/
public function setUserFramework($userFramework = NULL) {
$this->userFramework = $userFramework;
return CRM_Financial_BAO_PaymentProcessor::hasPaymentProcessorSupporting(array('BackOffice'));
}
+ /**
+ * Resets the singleton, so that the next call to CRM_Core_Config::singleton()
+ * reloads completely.
+ *
+ * While normally we could call the singleton function with $force = TRUE,
+ * this function addresses a very specific use-case in the CiviCRM installer,
+ * where we cannot yet force a reload, but we want to make sure that the next
+ * call to this object gets a fresh start (ex: to initialize the DAO).
+ */
+ public function free() {
+ self::$_singleton = NULL;
+ }
+
}