Permalink
Browse files

Merge branch 'MDL-58857-master' of git://github.com/andrewnicols/moodle

  • Loading branch information...
dmonllao committed May 10, 2017
2 parents 865e2bc + a011eff commit 265a1eafc5327df9189962aa18ef9e741ea0e90b
Showing with 31 additions and 7 deletions.
  1. +6 −0 admin/index.php
  2. +25 −7 lib/setuplib.php
@@ -101,6 +101,12 @@
// indirectly calls the protected init() method is good here.
core_component::get_core_subsystems();
if (is_major_upgrade_required() && isloggedin()) {
// A major upgrade is required.
// Terminate the session and redirect back here before anything DB-related happens.
redirect_if_major_upgrade_required();
}
require_once($CFG->libdir.'/adminlib.php'); // various admin-only functions
require_once($CFG->libdir.'/upgradelib.php'); // general upgrade/install related functions
@@ -1388,16 +1388,34 @@ function disable_output_buffering() {
}
/**
* Check whether a major upgrade is needed. That is defined as an upgrade that
* changes something really fundamental in the database, so nothing can possibly
* work until the database has been updated, and that is defined by the hard-coded
* version number in this function.
* Check whether a major upgrade is needed.
*
* That is defined as an upgrade that changes something really fundamental
* in the database, so nothing can possibly work until the database has
* been updated, and that is defined by the hard-coded version number in
* this function.
*
* @return bool
*/
function redirect_if_major_upgrade_required() {
function is_major_upgrade_required() {
global $CFG;
$lastmajordbchanges = 2017040403.00;
if (empty($CFG->version) or (float)$CFG->version < $lastmajordbchanges or
during_initial_install() or !empty($CFG->adminsetuppending)) {
$required = empty($CFG->version);
$required = $required || (float)$CFG->version < $lastmajordbchanges;
$required = $required || during_initial_install();
$required = $required || !empty($CFG->adminsetuppending);
return $required;
}
/**
* Redirect to the Notifications page if a major upgrade is required, and
* terminate the current user session.
*/
function redirect_if_major_upgrade_required() {
global $CFG;
if (is_major_upgrade_required()) {
try {
@\core\session\manager::terminate_current();
} catch (Exception $e) {

0 comments on commit 265a1ea

Please sign in to comment.