X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FConfig.php;h=d37ee5911ef5a9bfc035e57179b88c16fee8e432;hb=49692d2f70966661298e0d755b282b53f28391e5;hp=f4f909e450a8d1c1d651e3623a9f7db99bb40a8e;hpb=0880a9d0d6279d30564131892c9d71c2a3bb5903;p=civicrm-core.git diff --git a/CRM/Core/Config.php b/CRM/Core/Config.php index f4f909e450..d37ee5911e 100644 --- a/CRM/Core/Config.php +++ b/CRM/Core/Config.php @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.6 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2014 | + | Copyright CiviCRM LLC (c) 2004-2015 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -31,7 +31,7 @@ * The default values in general, should reflect production values (minimizes chances of screwing up) * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2014 + * @copyright CiviCRM LLC (c) 2004-2015 * $Id$ * */ @@ -402,7 +402,7 @@ class CRM_Core_Config extends CRM_Core_Config_Variables { } /** - * Initialize the DataObject framework + * Initialize the DataObject framework. * * @return void */ @@ -418,7 +418,7 @@ class CRM_Core_Config extends CRM_Core_Config_Variables { } /** - * Returns the singleton logger for the application + * Returns the singleton logger for the application. * * @param * @@ -433,7 +433,7 @@ class CRM_Core_Config extends CRM_Core_Config_Variables { } /** - * Initialize the config variables + * Initialize the config variables. * * @return void */ @@ -533,7 +533,7 @@ class CRM_Core_Config extends CRM_Core_Config_Variables { } /** - * 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. @@ -612,7 +612,7 @@ class CRM_Core_Config extends CRM_Core_Config_Variables { } /** - * 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(). @@ -632,7 +632,7 @@ class CRM_Core_Config extends CRM_Core_Config_Variables { } /** - * 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 @@ -803,24 +803,36 @@ class CRM_Core_Config extends CRM_Core_Config_Variables { /** * 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; @@ -877,4 +889,17 @@ AND 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; + } + }