Rewrite jquery.dashboard.js as Angular app
[civicrm-core.git] / CRM / Upgrade / Form.php
index e1f7bcd2def8c7ef36eff251144c621906b63ffb..2ab3c1c7e8d87d909d729d1638c3e331336e53e9 100644 (file)
@@ -25,7 +25,7 @@ class CRM_Upgrade_Form extends CRM_Core_Form {
   /**
    * Minimum previous CiviCRM version we can directly upgrade from
    */
-  const MINIMUM_UPGRADABLE_VERSION = '4.2.9';
+  const MINIMUM_UPGRADABLE_VERSION = '4.4.7';
 
   /**
    * @var \CRM_Core_Config
@@ -68,11 +68,10 @@ class CRM_Upgrade_Form extends CRM_Core_Form {
   ) {
     $this->_config = CRM_Core_Config::singleton();
 
-    $domain = new CRM_Core_DAO_Domain();
-    $domain->find(TRUE);
+    $locales = CRM_Core_I18n::getMultilingual();
 
-    $this->multilingual = (bool) $domain->locales;
-    $this->locales = explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales);
+    $this->multilingual = (bool) $locales;
+    $this->locales = $locales;
 
     $smarty = CRM_Core_Smarty::singleton();
     //$smarty->compile_dir = $this->_config->templateCompileDir;
@@ -168,7 +167,7 @@ class CRM_Upgrade_Form extends CRM_Core_Form {
       if (!isset($errorMessage)) {
         $errorMessage = 'pre-condition failed for current upgrade step';
       }
-      CRM_Core_Error::fatal($errorMessage);
+      throw new CRM_Core_Exception($errorMessage);
     }
     $this->assign('recentlyViewed', FALSE);
   }
@@ -234,7 +233,7 @@ class CRM_Upgrade_Form extends CRM_Core_Form {
       if (!isset($errorMessage)) {
         $errorMessage = 'post-condition failed for current upgrade step';
       }
-      CRM_Core_Error::fatal($errorMessage);
+      throw new CRM_Core_Exception($errorMessage);
     }
   }
 
@@ -287,19 +286,6 @@ SET    version = '$version'
     return FALSE;
   }
 
-  /**
-   * @param $version
-   *
-   * @return bool
-   */
-  public function checkVersion($version) {
-    $domainID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Domain',
-      $version, 'id',
-      'version'
-    );
-    return (bool) $domainID;
-  }
-
   /**
    * @return array
    * @throws Exception
@@ -385,7 +371,7 @@ SET    version = '$version'
     }
     else {
       if (!file_exists($sqlFile)) {
-        CRM_Core_Error::fatal("sqlfile - $rev.mysql not found.");
+        throw new CRM_Core_Exception("sqlfile - $rev.mysql not found.");
       }
       $this->source($sqlFile);
     }
@@ -400,13 +386,13 @@ SET    version = '$version'
     $latestVer = CRM_Utils_System::version();
     $currentVer = CRM_Core_BAO_Domain::version(TRUE);
     if (!$currentVer) {
-      CRM_Core_Error::fatal(ts('Version information missing in civicrm database.'));
+      throw new CRM_Core_Exception(ts('Version information missing in civicrm database.'));
     }
     elseif (stripos($currentVer, 'upgrade')) {
-      CRM_Core_Error::fatal(ts('Database check failed - the database looks to have been partially upgraded. You may want to reload the database with the backup and try the upgrade process again.'));
+      throw new CRM_Core_Exception(ts('Database check failed - the database looks to have been partially upgraded. You may want to reload the database with the backup and try the upgrade process again.'));
     }
     if (!$latestVer) {
-      CRM_Core_Error::fatal(ts('Version information missing in civicrm codebase.'));
+      throw new CRM_Core_Exception(ts('Version information missing in civicrm codebase.'));
     }
 
     return [$currentVer, $latestVer];
@@ -453,6 +439,16 @@ SET    version = '$version'
         ]);
     }
 
+    if (version_compare(CRM_Utils_SQL::getDatabaseVersion(), CRM_Upgrade_Incremental_General::MIN_INSTALL_MYSQL_VER) < 0) {
+      $error = ts('CiviCRM %4 requires MySQL version v%1 or MariaDB v%3 (or newer), but the current system uses %2 ',
+        [
+          1 => CRM_Upgrade_Incremental_General::MIN_INSTALL_MYSQL_VER,
+          2 => CRM_Utils_SQL::getDatabaseVersion(),
+          3 => '10.1',
+          4 => $latestVer,
+        ]);
+    }
+
     // check for mysql trigger privileges
     if (!\Civi::settings()->get('logging_no_trigger_permission') && !CRM_Core_DAO::checkTriggerViewPermission(FALSE, TRUE)) {
       $error = ts('CiviCRM %1 requires MySQL trigger privileges.',
@@ -510,7 +506,7 @@ SET    version = '$version'
 
     // Ensure that queue can be created
     if (!CRM_Queue_BAO_QueueItem::findCreateTable()) {
-      CRM_Core_Error::fatal(ts('Failed to find or create queueing table'));
+      throw new CRM_Core_Exception(ts('Failed to find or create queueing table'));
     }
     $queue = CRM_Queue_Service::singleton()->create([
       'name' => self::QUEUE_NAME,
@@ -707,7 +703,7 @@ SET    version = '$version'
     // pre-db check for major release.
     if ($upgrade->checkVersionRelease($rev, 'alpha1')) {
       if (!(is_callable([$versionObject, 'verifyPreDBstate']))) {
-        CRM_Core_Error::fatal("verifyPreDBstate method was not found for $rev");
+        throw new CRM_Core_Exception("verifyPreDBstate method was not found for $rev");
       }
 
       $error = NULL;
@@ -715,7 +711,7 @@ SET    version = '$version'
         if (!isset($error)) {
           $error = "post-condition failed for current upgrade for $rev";
         }
-        CRM_Core_Error::fatal($error);
+        throw new CRM_Core_Exception($error);
       }
 
     }