Skip to content

Commit

Permalink
CRM_Upgrade_Form::buildQueue - Scan CRM/Upgrade/Incremental/any/{VERS…
Browse files Browse the repository at this point in the history
…ION}/*
  • Loading branch information
totten committed Dec 10, 2015
1 parent 6fb3601 commit 444869b
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions CRM/Upgrade/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,8 @@ public static function buildQueue($currentVer, $latestVer, $postUpgradeMessageFi
);
$queue->createItem($beginTask);

// Traditional handler for files like CRM/Upgrade/Incremental/php/FourFour.php
// and CRM/Upgrade/Incremental/sql/*.mysql.tpl.
$task = new CRM_Queue_Task(
// callback
array('CRM_Upgrade_Form', 'doIncrementalUpgradeStep'),
Expand All @@ -603,6 +605,25 @@ public static function buildQueue($currentVer, $latestVer, $postUpgradeMessageFi
);
$queue->createItem($task);

// Newer handler for files like CRM/Upgrade/Incremental/any/{VERSION}/{*.php,*.mysql.tpl}
$incDir = implode(DIRECTORY_SEPARATOR,
array(dirname(__FILE__), 'Incremental', 'any', $rev)
);
if (is_dir($incDir)) {
$taskDir = new CRM_Queue_TaskDir($incDir);
$taskDir
->addCallback('/\.task\.php$/', array('CRM_Upgrade_Form', 'doPhpFileStep'))
->addCallback('/\.mysql\.tpl$/', array('CRM_Upgrade_Form', 'doSqlTplFileStep'))
->setTitle("Upgrade DB to $rev: {file.name}")
->setData(array(
'rev' => $rev,
'currentVer' => $currentVer,
'latestVer' => $latestVer,
'postUpgradeMessageFile' => $postUpgradeMessageFile,
))
->fill($queue);
}

$task = new CRM_Queue_Task(
// callback
array('CRM_Upgrade_Form', 'doIncrementalUpgradeFinish'),
Expand Down Expand Up @@ -693,6 +714,51 @@ public static function doIncrementalUpgradeStep(CRM_Queue_TaskContext $ctx, $rev
return TRUE;
}

/**
* Handle any file matching "CRM/Upgrade/Incremental/any/*.task.php".
*
* @param \CRM_Queue_TaskContext $ctx
* @param string $file
* @param array $data
* Array('rev'=>, 'latestVer'=>, ...).
* @return bool
* @throws \Exception
*/
public static function doPhpFileStep(CRM_Queue_TaskContext $ctx, $file, $data) {
$stack = CRM_Utils_GlobalStack::singleton();
$stack->push(array(
'_TASK' => array('ctx' => $ctx, 'file' => $file) + $data,
));

try {
include $file;
}
catch (Exception $e) {
$stack->pop();
throw $e;
}

$stack->pop();
return TRUE;
}

/**
* Handle any file matching "CRM/Upgrade/Incremental/any/*.mysql.tpl".
*
* @param \CRM_Queue_TaskContext $ctx
* @param string $file
* @param array $data
* Array('rev'=>, 'latestVer'=>, ...).
* @return bool
* @throws \Exception
*/
public static function doSqlTplFileStep(CRM_Queue_TaskContext $ctx, $file, $data) {
$upgrade = new CRM_Upgrade_Form();
$upgrade->processLocales($file, $data['rev']);
return TRUE;
}


/**
* Perform an incremental version update.
*
Expand Down
Empty file.

0 comments on commit 444869b

Please sign in to comment.