Commit 0284f9ab authored by Aaron Wells's avatar Aaron Wells

Removing obsolete "disablelogin" setting

Bug 1526076: I believe the initial intent was that
Mahara core, and/or each plugin, could add a value
to its version.php file indicating "disablelogin"
true or false. And in this way, an upgrade could
indicate whether it was a small enough upgrade that
users did not need to log out for it.

However, in practice this is not practical because
we don't know what version of Mahara the user is
upgrading from, and that is what determines whether
or not it's a "stable" upgrade.

Additionally, the core disablelogin has been set to true
for the past 7 years, and the plugin disablelogin
setting no longer has any effect.

Removing disablelogin should hopefully make our
maze of init.php auth_setup() login stuff a little
bit easier to follow.

behatnotneeded: Covered by existing tests

Change-Id: I5f8a2b4faa95b9225bb926de6a54a622ea1a9618
parent 1404fe80
......@@ -22,9 +22,6 @@ $name = param_variable('name');
$install = ($name == 'firstcoredata' || $name == 'lastcoredata' || $name == 'localpreinst' || $name == 'localpostinst');
if (!$install) {
$upgrade = check_upgrades($name);
if (!empty($upgrade) && empty($upgrade->disablelogin)) {
auth_setup();
}
}
raise_time_limit(120);
raise_memory_limit('256M');
......
......@@ -50,9 +50,6 @@ else {
$smarty->assign('upgradeheading', get_string('performingupgrades', 'admin'));
}
if (empty($upgrades['settings']['disablelogin'])) {
auth_setup();
}
// Remove the "settings" component, which is not a real component (see check_upgrades())
unset($upgrades['settings']);
......
......@@ -444,13 +444,12 @@ function login_test_all_user_authinstance($username, $password) {
}
// stop right here if the site is closed for any reason
$siteclosedforupgrade = get_config('siteclosedforupgrade');
if ($siteclosedforupgrade && get_config('disablelogin')) {
if (get_config('siteclosedforupgrade')) {
global $SESSION;
$SESSION->add_error_msg(get_string('siteclosedlogindisabled', 'mahara', get_config('wwwroot') . 'admin/upgrade.php'), false);
return false;
}
if ($siteclosedforupgrade || get_config('siteclosedbyadmin')) {
if (get_config('siteclosedbyadmin')) {
global $SESSION;
$SESSION->add_error_msg(get_string('siteclosed'));
return false;
......
......@@ -1863,15 +1863,19 @@ class LiveUser extends User {
}
}
function is_site_closed($adminuser) {
$siteclosedforupgrade = get_config('siteclosedforupgrade');
if ($siteclosedforupgrade && get_config('disablelogin')) {
/**
* Indicates whether the site is closed for a user
* @param boolean $isuseradmin Whether the user we're checking for is an admin
* @return boolean True if the site is closed; False if not
*/
function is_site_closed($isuseradmin) {
if (get_config('siteclosedforupgrade')) {
global $SESSION;
$SESSION->add_error_msg(get_string('siteclosedlogindisabled', 'mahara', get_config('wwwroot') . 'admin/upgrade.php'), false);
return true;
}
if (!$adminuser && ($siteclosedforupgrade || get_config('siteclosedbyadmin'))) {
if (!$isuseradmin && get_config('siteclosedbyadmin')) {
global $SESSION;
$SESSION->add_error_msg(get_string('siteclosed'));
return true;
......
......@@ -348,11 +348,8 @@ if (get_config('installed')) {
if ($upgradeavailable) {
ensure_upgrade_sanity();
}
$disablelogin = $config->disablelogin;
$cfgsiteclosed = get_config('siteclosedforupgrade');
if ($upgradeavailable != $cfgsiteclosed) {
if ($upgradeavailable != get_config('siteclosedforupgrade')) {
set_config('siteclosedforupgrade', $upgradeavailable);
set_config('disablelogin', $disablelogin);
}
}
......@@ -392,15 +389,6 @@ try {
$SESSION->add_error_msg($exception->getMessage());
}
if ($siteclosedforupgrade && $USER->admin) {
if (get_config('disablelogin')) {
$USER->logout();
}
else if (!defined('INSTALLER')) {
redirect('/admin/upgrade.php');
}
}
// The installer does its own auth_setup checking, because some upgrades may
// break logging in and so need to allow no logins.
// Command-line scripts obviously have no logged-in user.
......@@ -408,8 +396,10 @@ if (!defined('INSTALLER') && !defined('CLI') && !defined('CRON')) {
auth_setup();
}
$siteclosed = $siteclosedforupgrade || get_config('siteclosedbyadmin');
if ($siteclosed && !$USER->admin) {
// Force the user to log out if:
// - the site is closed by the system due to a pending upgrade
// - the site was closed by an admin (and the user is not an admin)
if ($siteclosedforupgrade || (get_config('siteclosedbyadmin') && !$USER->admin)) {
if ($USER->is_logged_in()) {
$USER->logout();
}
......
......@@ -43,13 +43,9 @@ function check_upgrades($name=null) {
$toupgradecount = 0;
$newinstallcount = 0;
$installing = false;
$disablelogin = false;
$newinstalls = array();
require('version.php');
if (isset($config->disablelogin) && !empty($config->disablelogin)) {
$disablelogin = true;
}
// check core first...
if (empty($name) || $name == 'core') {
try {
......@@ -105,7 +101,6 @@ function check_upgrades($name=null) {
// If we were just checking if the core needed to be upgraded, we can stop here
if ($name == 'core') {
$toupgrade['core']->disablelogin = $disablelogin;
return $toupgrade['core'];
}
......@@ -132,7 +127,6 @@ function check_upgrades($name=null) {
}
if ($name == 'local') {
$toupgrade['local']->disablelogin = $disablelogin;
return $toupgrade['local'];
}
}
......@@ -224,9 +218,6 @@ function check_upgrades($name=null) {
$config = new StdClass;
require(get_config('docroot') . $pluginpath . '/version.php');
if (isset($config->disablelogin) && !empty($config->disablelogin)) {
$disablelogin = true;
}
if (empty($pluginversion)) {
$newinstall = false;
......@@ -313,7 +304,6 @@ function check_upgrades($name=null) {
foreach ((array)$toupgrade[$name] as $key => $value) {
$upgrade->{$key} = $value;
}
$upgrade->disablelogin = $disablelogin;
return $upgrade;
}
else {
......@@ -321,15 +311,8 @@ function check_upgrades($name=null) {
}
}
// Nothing needed to be upgraded or installed
if (count($toupgrade) == 0) {
if (!empty($name))
$disablelogin = false;
}
// If we get here, it's because we have an array of objects to return
uksort($toupgrade, 'sort_upgrades');
$settings['disablelogin'] = $disablelogin;
$settings['newinstallcount'] = $newinstallcount;
$settings['newinstalls'] = $newinstalls;
$settings['toupgradecount'] = $toupgradecount;
......
......@@ -21,4 +21,3 @@ $config->series = '16.04';
$config->release = '16.04dev';
$config->minupgradefrom = 2012080604;
$config->minupgraderelease = '1.6.0 (release tag 1.6.0_RELEASE)';
$config->disablelogin = true;
......@@ -646,11 +646,10 @@ EOF;
$smarty->assign('RELEASE', get_config('release'));
$smarty->assign('SERIES', get_config('series'));
$smarty->assign('CACHEVERSION', get_config('cacheversion'));
$siteclosedforupgrade = get_config('siteclosedforupgrade');
if ($siteclosedforupgrade && get_config('disablelogin')) {
if (get_config('siteclosedforupgrade')) {
$smarty->assign('SITECLOSED', 'logindisabled');
}
else if ($siteclosedforupgrade || get_config('siteclosedbyadmin')) {
else if (get_config('siteclosedbyadmin')) {
$smarty->assign('SITECLOSED', 'loginallowed');
}
......@@ -755,7 +754,7 @@ EOF;
);
}
$isloginblockvisible = !$USER->is_logged_in() && !(get_config('siteclosedforupgrade') && get_config('disablelogin'))
$isloginblockvisible = !$USER->is_logged_in() && !get_config('siteclosedforupgrade')
&& get_config('showloginsideblock');
if ($isloginblockvisible) {
$sideblocks[] = array(
......
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