/** * Determine if $currentVer can be upgraded to $latestVer * * @param $currentVer * @param $latestVer * * @return mixed, a string error message or boolean 'false' if OK */ public function checkUpgradeableVersion($currentVer, $latestVer) { $error = FALSE; // since version is suppose to be in valid format at this point, especially after conversion ($convertVer), // lets do a pattern check - if (!CRM_Utils_System::isVersionFormatValid($currentVer)) { $error = ts('Database is marked with invalid version format. You may want to investigate this before you proceed further.'); } elseif (version_compare($currentVer, $latestVer) > 0) { // DB version number is higher than codebase being upgraded to. This is unexpected condition-fatal error. $error = ts('Your database is marked with an unexpected version number: %1. The automated upgrade to version %2 can not be run - and the %2 codebase may not be compatible with your database state. You will need to determine the correct version corresponding to your current database state. You may want to revert to the codebase you were using prior to beginning this upgrade until you resolve this problem.', array(1 => $currentVer, 2 => $latestVer)); } elseif (version_compare($currentVer, $latestVer) == 0) { $error = ts('Your database has already been upgraded to CiviCRM %1', array(1 => $latestVer)); } elseif (version_compare($currentVer, self::MINIMUM_UPGRADABLE_VERSION) < 0) { $error = ts('CiviCRM versions prior to %1 cannot be upgraded directly to %2. This upgrade will need to be done in stages. First download an intermediate version (the LTS may be a good choice) and upgrade to that before proceeding to this version.', array(1 => self::MINIMUM_UPGRADABLE_VERSION, 2 => $latestVer)); } if (version_compare(phpversion(), self::MINIMUM_PHP_VERSION) < 0) { $error = ts('CiviCRM %3 requires PHP version %1 (or newer), but the current system uses %2 ', array(1 => self::MINIMUM_PHP_VERSION, 2 => phpversion(), 3 => $latestVer)); } // check for mysql trigger privileges if (!CRM_Core_DAO::checkTriggerViewPermission(FALSE, TRUE)) { $error = ts('CiviCRM %1 requires MySQL trigger privileges.', array(1 => $latestVer)); } 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)); } return $error; }