Commit 5d1ea9b3 authored by Aaron Wells's avatar Aaron Wells Committed by Robert Lyon

Fixing cli install / upgrade regression (Bug #1367998)

When you request that check_upgrades() checks for upgrades in all
components, the return data now includes a false component called
"settings". I've moved "disablelogin", "newinstallcount" and "toupgradecount" into that settings component.

Change-Id: I57e26e0e05848da607b8a44089c92547ebda078b
parent ee37a85f
......@@ -47,10 +47,11 @@ else {
$smarty->assign('upgradeheading', get_string('performingupgrades', 'admin'));
}
if (empty($upgrades['disablelogin'])) {
if (empty($upgrades['settings']['disablelogin'])) {
auth_setup();
}
unset($upgrades['disablelogin']);
// Remove the "settings" component, which is not a real component (see check_upgrades())
unset($upgrades['settings']);
if (!$upgrades) {
die_info(get_string('noupgrades', 'admin'));
......@@ -129,11 +130,6 @@ if (!empty($upgrades['core']->install)) {
$upgrades['localpostinst'] = true;
$smarty->assign('install', true);
}
// If we are coming from the upgrade plugins on the 'Admin home' page
if (isset($upgrades['newinstallcount'])) {
unset($upgrades['newinstallcount']);
unset($upgrades['toupgradecount']);
}
foreach ($upgrades as $key => $upgrade) {
if (isset($upgrade->newinstall)) {
unset($upgrades[$key]);
......
......@@ -211,7 +211,7 @@ function upgrade_mahara($upgrades) {
}
uksort($upgrades, 'sort_upgrades');
foreach ($upgrades as $name => $data) {
if ($name == 'disablelogin') {
if ($name == 'settings') {
continue;
}
if ($install) {
......
......@@ -153,7 +153,7 @@ class UnitTestBootstrap {
$upgrades['lastcoredata'] = true;
uksort($upgrades, 'sort_upgrades');
foreach ($upgrades as $name => $data) {
if ($name == 'disablelogin') {
if ($name == 'settings') {
continue;
}
log_info('Installing ' . $name);
......
......@@ -27,13 +27,18 @@ require_once('ddl.php');
*
* @param string $name The name of the plugin to check. If no name is specified,
* all plugins are checked.
* @return array of objects
* @return mixed If a name is specified, an obect will be returned with upgrade data
* about the requested plugin.
* If no name is specified, an array of such objects will be returned.
* It will also include an array key "settings", which will be an array
* that may contain metadata about the upgrade/install process.
*/
function check_upgrades($name=null) {
$pluginstocheck = plugin_types();
$toupgrade = array();
$settings = array();
$toupgradecount = 0;
$newinstallcount = 0;
$installing = false;
......@@ -305,13 +310,18 @@ function check_upgrades($name=null) {
$upgrade->disablelogin = $disablelogin;
return $upgrade;
}
$toupgrade['disablelogin'] = $disablelogin;
if (count($toupgrade) == 1) {
$toupgrade = array();
// Nothing needed to be upgraded or installed
if (count($toupgrade) == 0) {
$disablelogin = false;
}
// If we get here, it's because we have an array of objects to return
uksort($toupgrade, 'sort_upgrades');
$toupgrade['newinstallcount'] = $newinstallcount;
$toupgrade['toupgradecount'] = $toupgradecount;
$settings['disablelogin'] = $disablelogin;
$settings['newinstallcount'] = $newinstallcount;
$settings['toupgradecount'] = $toupgradecount;
$toupgrade['settings'] = $settings;
return $toupgrade;
}
......
......@@ -11,7 +11,7 @@
</div>
{/if}
{if $upgrades['toupgradecount']}
{if $upgrades['settings']['toupgradecount']}
<div class="message" id="runupgrade">
<h3>{str tag="upgrades" section=admin}</h3>
<div class="fr"><span class="upgrade"><a class="btn" href="upgrade.php">{str tag=runupgrade section=admin}</a></span></div>
......@@ -26,7 +26,7 @@
</thead>
<tbody>
{foreach from=$upgrades key=key item=upgrade}
{if $key != 'disablelogin' && $upgrade->upgrade}
{if $key != 'settings' && $upgrade->upgrade}
<tr>
<td><strong>{$key}</strong></td>
<td>{$upgrade->fromrelease} ({$upgrade->from})</td>
......@@ -39,7 +39,7 @@
</div>
{/if}
{if $upgrades['newinstallcount']}
{if $upgrades['settings']['newinstallcount']}
<div class="warning" id="runinstall">
<h3>{str tag="newplugins" section=admin}</h3>
<div class="fr"><span class="upgrade"><a class="btn" href="extensions/plugins.php">{str tag=gotoinstallpage section=admin}</a></span></div>
......@@ -54,7 +54,7 @@
</thead>
<tbody>
{foreach from=$upgrades key=key item=upgrade}
{if $key != 'disablelogin' && $upgrade->install}
{if $key != 'settings' && $upgrade->install}
<tr>
<td><strong>{$key}</strong></td>
<td>{$upgrade->fromrelease}</td>
......
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