CRM-16860 - Refactor out CRM_Upgrade_Incremental_Legacy
authorColeman Watts <coleman@civicrm.org>
Fri, 24 Jul 2015 01:46:36 +0000 (21:46 -0400)
committerColeman Watts <coleman@civicrm.org>
Fri, 24 Jul 2015 15:27:46 +0000 (11:27 -0400)
CRM/Upgrade/Form.php
CRM/Upgrade/Incremental/General.php [moved from CRM/Upgrade/Incremental/Legacy.php with 92% similarity]

index e2dcf1ca3ce40651025ddb2d7b2ec4195bdc813d..b3eed3f6e523d6c80654f6d968a3d1a88363a258 100644 (file)
@@ -763,21 +763,19 @@ SET    version = '$version'
    * @param $latestVer
    */
   public function setPreUpgradeMessage(&$preUpgradeMessage, $currentVer, $latestVer) {
-    CRM_Upgrade_Incremental_Legacy::setPreUpgradeMessage($preUpgradeMessage, $currentVer, $latestVer);
+    // check for changed message templates
+    CRM_Upgrade_Incremental_General::checkMessageTemplate($preUpgradeMessage, $latestVer, $currentVer);
+    // set global messages
+    CRM_Upgrade_Incremental_General::setPreUpgradeMessage($preUpgradeMessage, $currentVer, $latestVer);
 
     // Scan through all php files and see if any file is interested in setting pre-upgrade-message
     // based on $currentVer, $latestVer.
     // Please note, at this point upgrade hasn't started executing queries.
     $revisions = $this->getRevisionSequence();
     foreach ($revisions as $rev) {
-      if (version_compare($currentVer, $rev) < 0 &&
-        version_compare($rev, '3.2.alpha1') > 0
-      ) {
+      if (version_compare($currentVer, $rev) < 0) {
         $versionObject = $this->incrementalPhpObject($rev);
-        if (is_callable(array(
-          $versionObject,
-          'setPreUpgradeMessage',
-        ))) {
+        if (is_callable(array($versionObject, 'setPreUpgradeMessage'))) {
           $versionObject->setPreUpgradeMessage($preUpgradeMessage, $rev, $currentVer);
         }
       }
similarity index 92%
rename from CRM/Upgrade/Incremental/Legacy.php
rename to CRM/Upgrade/Incremental/General.php
index f9a9aae2cb354a19d0cd09d771b262d9894a2d34..8d858628469804cd013372be2a68b9a6c6456770 100644 (file)
  */
 
 /**
- * This class is a container for legacy upgrade logic which predates
- * the current 'CRM/Incremental/php/*' structure.
+ * This class contains generic upgrade logic which runs regardless of version.
  */
-class CRM_Upgrade_Incremental_Legacy {
+class CRM_Upgrade_Incremental_General {
 
   /**
    * Compute any messages which should be displayed before upgrade.
@@ -48,12 +47,6 @@ class CRM_Upgrade_Incremental_Legacy {
    * @param $latestVer
    */
   public static function setPreUpgradeMessage(&$preUpgradeMessage, $currentVer, $latestVer) {
-    $upgrade = new CRM_Upgrade_Form();
-    $template = CRM_Core_Smarty::singleton();
-
-    // check for changed message templates
-    self::checkMessageTemplate($template, $preUpgradeMessage, $latestVer, $currentVer);
-
     // http://issues.civicrm.org/jira/browse/CRM-13572
     // Depending on how the code was upgraded, some sites may still have copies of old
     // source files left behind. This is often a forgivable offense, but it's quite
@@ -88,12 +81,11 @@ class CRM_Upgrade_Incremental_Legacy {
   }
 
   /**
-   * @param $template
    * @param $message
    * @param $latestVer
    * @param $currentVer
    */
-  public static function checkMessageTemplate(&$template, &$message, $latestVer, $currentVer) {
+  public static function checkMessageTemplate(&$message, $latestVer, $currentVer) {
 
     $sql = "SELECT orig.workflow_id as workflow_id,
              orig.msg_title as title
@@ -106,7 +98,7 @@ class CRM_Upgrade_Incremental_Legacy {
                 )
             )";
 
-    $dao = &CRM_Core_DAO::executeQuery($sql);
+    $dao = CRM_Core_DAO::executeQuery($sql);
     while ($dao->fetch()) {
       $workflows[$dao->workflow_id] = $dao->title;
     }