Commit 0e1704c1 authored by Aaron Wells's avatar Aaron Wells

CLI upgrader, better handling of out-of-sequence plugin upgrades

Bug 1614805. When a plugin is installed "out of sequence" by a
call to plugin_upgrade in the core lib/db/upgrade.php file, the
AJAX-based web upgrader handles it gracefully, because it does
check_upgrade() before upgrading each plugin, detects the change
in status, and doesn't run the upgrade for that plugin a second
time.

The CLI upgrader, on the other hand, uses the same cached data
from check_upgrades() all the way through, causing it to re-run
upgrades for such plugins.

This patch makes it behave the same as the AJAX plugin, running
check_upgrade() again immediately before each component gets
upgraded. This does cause some redundancy in code execution,
but it shouldn't be enough to cause a noticeable performance hit.

Change-Id: Id5c431fc9e636df2cab05d22e6cc424271ce9f3d
behatnotneeded: Covered by existing tests
parent 7e555998
......@@ -47,4 +47,9 @@ ensure_upgrade_sanity();
// Actually perform the upgrade
log_info(get_string('cliupgradingmahara', 'admin'));
upgrade_mahara($upgrades);
foreach ($upgrades as $name => $data) {
// Check to make sure the plugin hasn't already been update out-of-sequence
if ($name != 'settings' && $newdata = check_upgrades($name)) {
upgrade_mahara(array($name => $newdata));
}
}
......@@ -207,6 +207,7 @@ function ensure_upgrade_sanity() {
/**
* Upgrade/Install the specified mahara components
* (Only used by the CLI installer & upgrader)
*
* @param array $upgrades The list of components to install or upgrade
* @return void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment