Merge pull request #3004 from sgladstone/master
[civicrm-core.git] / CRM / Upgrade / Form.php
index ba7d885e8502f73ea8a1182a8c893fed209c1bdf..60c313fcea8935f269141745c8b0a415c7559cba 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.3                                                |
+ | CiviCRM version 4.5                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
  * $Id$
  *
  */
@@ -121,7 +121,8 @@ class CRM_Upgrade_Form extends CRM_Core_Form {
     $versionName = self::$_numberMap[$versionParts[0]] . self::$_numberMap[$versionParts[1]];
 
     if (!array_key_exists($versionName, $incrementalPhpObject)) {
-      eval("\$incrementalPhpObject['$versionName'] = new CRM_Upgrade_Incremental_php_{$versionName};");
+      $className = "CRM_Upgrade_Incremental_php_{$versionName}";
+      $incrementalPhpObject[$versionName] = new $className();
     }
     return $incrementalPhpObject[$versionName];
   }
@@ -394,7 +395,7 @@ SET    version = '$version'
                array(
                  1 => $minPhpVersion,
                  2 => $phpVersion,
-                 3 => $latestVer,
+                 3 => $latestVer
                ));
     }
 
@@ -407,7 +408,7 @@ SET    version = '$version'
     if (CRM_Core_DAO::getGlobalSetting('thread_stack', 0) < (1024*self::MINIMUM_THREAD_STACK)) {
       $error = ts('CiviCRM %1 requires MySQL thread stack >= %2k', array(
         1 => $latestVer,
-        2 => self::MINIMUM_THREAD_STACK,
+        2 => self::MINIMUM_THREAD_STACK
       ));
     }
 
@@ -489,7 +490,7 @@ SET    version = '$version'
           // callback
           array('CRM_Upgrade_Form', 'doIncrementalUpgradeFinish'),
           // arguments
-          array($rev),
+          array($rev, $currentVer, $latestVer, $postUpgradeMessageFile),
           "Finish Upgrade DB to $rev"
         );
         $queue->createItem($task);
@@ -597,14 +598,13 @@ SET    version = '$version'
    * @param $latestVer string, the target (final) revision
    * @param $postUpgradeMessageFile string, path of a modifiable file which lists the post-upgrade messages
    */
-  static function doIncrementalUpgradeFinish(CRM_Queue_TaskContext $ctx, $rev) {
+  static function doIncrementalUpgradeFinish(CRM_Queue_TaskContext $ctx, $rev, $currentVer, $latestVer, $postUpgradeMessageFile) {
     $upgrade = new CRM_Upgrade_Form();
     $upgrade->setVersion($rev);
     CRM_Utils_System::flushCache();
 
-    if (version_compare($currentVer, '4.1.alpha1') >= 0) {
-      CRM_Core_BAO_Setting::updateSettingsFromMetaData();
-    }
+    $config = CRM_Core_Config::singleton();
+    $config->userSystem->flush();
     return TRUE;
   }
 
@@ -620,9 +620,13 @@ SET    version = '$version'
     $params = array();
     CRM_Core_BAO_ConfigSetting::add($params);
 
+    // CRM-12804 comment-51411 : add any missing settings
+    // at the end of upgrade
+    CRM_Core_BAO_Setting::updateSettingsFromMetaData();
+
     // cleanup caches CRM-8739
     $config = CRM_Core_Config::singleton();
-    $config->cleanupCaches(1, FALSE);
+    $config->cleanupCaches(1);
 
     // Rebuild all triggers and re-enable logging if needed
     $logging = new CRM_Logging_Schema();