/** * Perform an incremental version update. * * @param CRM_Queue_TaskContext $ctx * @param string $rev * the target (intermediate) revision e.g '3.2.alpha1'. * @param string $originalVer * the original revision. * @param string $latestVer * the target (final) revision. * @param string $postUpgradeMessageFile * path of a modifiable file which lists the post-upgrade messages. * * @return bool */ public static function doIncrementalUpgradeStep(CRM_Queue_TaskContext $ctx, $rev, $originalVer, $latestVer, $postUpgradeMessageFile) { $upgrade = new CRM_Upgrade_Form(); $phpFunctionName = 'upgrade_' . str_replace('.', '_', $rev); $versionObject = $upgrade->incrementalPhpObject($rev); // pre-db check for major release. if ($upgrade->checkVersionRelease($rev, 'alpha1')) { if (!is_callable(array($versionObject, 'verifyPreDBstate'))) { CRM_Core_Error::fatal("verifyPreDBstate method was not found for {$rev}"); } $error = NULL; if (!$versionObject->verifyPreDBstate($error)) { if (!isset($error)) { $error = "post-condition failed for current upgrade for {$rev}"; } CRM_Core_Error::fatal($error); } } $upgrade->setSchemaStructureTables($rev); if (is_callable(array($versionObject, $phpFunctionName))) { $versionObject->{$phpFunctionName}($rev, $originalVer, $latestVer); } else { $upgrade->processSQL($rev); } // set post-upgrade-message if any if (is_callable(array($versionObject, 'setPostUpgradeMessage'))) { $postUpgradeMessage = file_get_contents($postUpgradeMessageFile); $versionObject->setPostUpgradeMessage($postUpgradeMessage, $rev); file_put_contents($postUpgradeMessageFile, $postUpgradeMessage); } return TRUE; }