Commit b4c1755f authored by Aaron Wells's avatar Aaron Wells Committed by Gerrit Code Review

Bug 1427901: Performance improvements for cron

- Cron doesn't need to run auth_setup()
- Don't run cron when site is closed for upgrade
- Get rid of forcelocalupgrade() option because it's no longer needed

Change-Id: I1718b13337c50fadc0573d04f5b3d6b20bc842c2
parent 83725570
......@@ -390,27 +390,6 @@ function auth_setup () {
return;
}
// Lock the site until core upgrades are done
require(get_config('libroot') . 'version.php');
$siteclosed = $config->version > get_config('version');
$disablelogin = $config->disablelogin;
if (!$siteclosed && get_config('forcelocalupgrades')) {
require(get_config('docroot') . 'local/version.php');
$siteclosed = $config->version > get_config('localversion');
}
$cfgsiteclosed = get_config('siteclosed');
if ($siteclosed && !$cfgsiteclosed || !$siteclosed && $cfgsiteclosed) {
// If the admin closed the site manually, open it automatically
// when an upgrade is successful.
if ($cfgsiteclosed && get_config('siteclosedbyadmin')) {
set_config('siteclosedbyadmin', false);
}
set_config('siteclosed', $siteclosed);
set_config('disablelogin', $disablelogin);
}
// Check the time that the session is set to log out. If the user does
// not have a session, this time will be 0.
$sessionlogouttime = $USER->get('logout_time');
......
......@@ -373,6 +373,25 @@ if (!get_config('productionmode')) {
$CFG->nocache = true;
}
if (get_config('installed')) {
// Check whether core upgrades need to be done. If so, "close" the site
// from logins
require(get_config('libroot') . 'version.php');
$upgradeavailable = $config->version > get_config('version');
$disablelogin = $config->disablelogin;
$cfgsiteclosed = get_config('siteclosed');
if ($upgradeavailable != $cfgsiteclosed) {
set_config('siteclosed', $upgradeavailable);
set_config('disablelogin', $disablelogin);
}
}
// If we're in the middle of an upgrade, quit the cron now.
$siteclosedforupgrade = get_config('siteclosed');
if ($siteclosedforupgrade && defined('CRON')) {
exit("Site closed for upgrade.\n");
}
if (!defined('CLI')) {
header('Content-type: text/html; charset=UTF-8');
// Ensure that, by default, the response is not cached
......@@ -403,14 +422,6 @@ try {
$SESSION->add_error_msg($exception->getMessage());
}
// 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.
if (!defined('INSTALLER') && !defined('CLI')) {
auth_setup();
}
$siteclosedforupgrade = get_config('siteclosed');
if ($siteclosedforupgrade && $USER->admin) {
if (get_config('disablelogin')) {
$USER->logout();
......@@ -420,6 +431,13 @@ if ($siteclosedforupgrade && $USER->admin) {
}
}
// 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.
if (!defined('INSTALLER') && !defined('CLI') && !defined('CRON')) {
auth_setup();
}
$siteclosed = $siteclosedforupgrade || get_config('siteclosedbyadmin');
if ($siteclosed && !$USER->admin) {
if ($USER->is_logged_in()) {
......
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