Commit d7cd332d authored by Cecilia Vela Gurovic's avatar Cecilia Vela Gurovic Committed by Gerrit Code Review

Merge "Bug 1839549: Allow CLI upgrade to set / unset _upgrade flag"

parents f304ce09 a8b65f92
......@@ -24,13 +24,19 @@ require(get_config('docroot') . 'local/install.php');
$cli = get_cli();
$options = array();
$options['force'] = (object) array(
'shortoptions' => array('f'),
'description' => get_string('cli_upgrade_force', 'admin'),
'required' => false,
'defaultvalue' => false,
);
$settings = new stdClass();
$settings->options = $options;
$settings->info = get_string('cliupgraderdescription', 'admin');
$settings->info = get_string('cli_upgrade_description', 'admin');
$cli->setup($settings);
$force = $cli->get_cli_param('force');
// Check whether Mahara is installed yet
if (!table_exists(new XMLDBTable('config'))) {
cli::cli_exit(get_string('maharanotinstalled', 'admin'), false);
......@@ -45,14 +51,28 @@ if (empty($upgrades['settings']['toupgradecount'])) {
// Check for issues which would pose problems during upgrade
ensure_upgrade_sanity();
if (get_field('config', 'value', 'field', '_upgrade')) {
if ($force) {
// delete the old flag
delete_records('config', 'field', '_upgrade');
}
else {
cli::cli_exit(get_string('cli_upgrade_flag', 'admin'), false);
}
}
// set the flag for this run
insert_record('config', (object) array('field' => '_upgrade', 'value' => time()));
// Clear all caches
clear_all_caches();
// Actually perform the upgrade
log_info(get_string('cliupgradingmahara', 'admin'));
log_info(get_string('cli_upgrade_title', 'admin'));
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));
}
}
// upgrade completed so remove any upgrade holds
delete_records('config', 'field', '_upgrade');
......@@ -59,8 +59,12 @@ $string['clisitename'] = 'The site name';
$string['cliupdatesitenamefailed'] = 'Updating site name failed.';
$string['cliinstallerdescription'] = 'Install Mahara and create required data directories';
$string['cliinstallingmahara'] = 'Installing Mahara';
$string['cliupgraderdescription'] = 'Upgrade the Mahara database and data to the version of Mahara installed';
$string['cliupgradingmahara'] = 'Upgrading Mahara';
// CLI upgrade script
$string['cli_upgrade_description'] = 'Upgrade the Mahara database and data to the version of Mahara installed';
$string['cli_upgrade_title'] = 'Upgrading Mahara';
$string['cli_upgrade_force'] = 'Force upgrade to rerun';
$string['cli_upgrade_flag'] = 'An unfinished upgrade detected. To try upgrading again add "-f" option to the command.';
$string['cliclearingcaches'] = 'Clearing Mahara caches.';
$string['cliclearcachesdescription'] = 'Clearing caches will delete cached data from the server. There is no danger in clearing caches, but your site may appear slower for a while until the server and clients calculate new information and cache it.';
$string['clearcachesheading'] = 'Clear caches';
......
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