MDL-41384 upgrade: make sure to re-read $SITE from DB when course table is altered
This commit is contained in:
+26
-1
@@ -85,7 +85,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @return bool always true
|
||||
*/
|
||||
function xmldb_main_upgrade($oldversion) {
|
||||
global $CFG, $USER, $DB, $OUTPUT, $SITE;
|
||||
global $CFG, $USER, $DB, $OUTPUT, $SITE, $COURSE;
|
||||
|
||||
require_once($CFG->libdir.'/db/upgradelib.php'); // Core Upgrade-related functions
|
||||
|
||||
@@ -316,6 +316,10 @@ function xmldb_main_upgrade($oldversion) {
|
||||
$dbman->drop_field($table, $field);
|
||||
}
|
||||
|
||||
// Since structure of 'course' table has changed we need to re-read $SITE from DB.
|
||||
$SITE = $DB->get_record('course', array('id' => $SITE->id));
|
||||
$COURSE = clone($SITE);
|
||||
|
||||
upgrade_main_savepoint(true, 2012031500.02);
|
||||
}
|
||||
|
||||
@@ -447,6 +451,10 @@ function xmldb_main_upgrade($oldversion) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Since structure of 'course' table has changed we need to re-read $SITE from DB.
|
||||
$SITE = $DB->get_record('course', array('id' => $SITE->id));
|
||||
$COURSE = clone($SITE);
|
||||
|
||||
// Main savepoint reached
|
||||
upgrade_main_savepoint(true, 2012050300.03);
|
||||
}
|
||||
@@ -563,6 +571,10 @@ function xmldb_main_upgrade($oldversion) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Since structure of 'course' table has changed we need to re-read $SITE from DB.
|
||||
$SITE = $DB->get_record('course', array('id' => $SITE->id));
|
||||
$COURSE = clone($SITE);
|
||||
|
||||
// Add course_sections_availability to add completion & grade availability conditions
|
||||
$table = new xmldb_table('course_sections_availability');
|
||||
|
||||
@@ -1336,6 +1348,10 @@ function xmldb_main_upgrade($oldversion) {
|
||||
// Launch change of type for field format
|
||||
$dbman->change_field_type($table, $field);
|
||||
|
||||
// Since structure of 'course' table has changed we need to re-read $SITE from DB.
|
||||
$SITE = $DB->get_record('course', array('id' => $SITE->id));
|
||||
$COURSE = clone($SITE);
|
||||
|
||||
// Main savepoint reached
|
||||
upgrade_main_savepoint(true, 2012110200.00);
|
||||
}
|
||||
@@ -1388,6 +1404,10 @@ function xmldb_main_upgrade($oldversion) {
|
||||
}
|
||||
}
|
||||
|
||||
// Since structure of 'course' table has changed we need to re-read $SITE from DB.
|
||||
$SITE = $DB->get_record('course', array('id' => $SITE->id));
|
||||
$COURSE = clone($SITE);
|
||||
|
||||
// Main savepoint reached
|
||||
upgrade_main_savepoint(true, 2012110201.00);
|
||||
}
|
||||
@@ -1504,6 +1524,7 @@ function xmldb_main_upgrade($oldversion) {
|
||||
if ($SITE->format !== 'site') {
|
||||
$DB->set_field('course', 'format', 'site', array('id' => $SITE->id));
|
||||
$SITE->format = 'site';
|
||||
$COURSE->format = 'site';
|
||||
}
|
||||
|
||||
// Main savepoint reached
|
||||
@@ -1993,6 +2014,10 @@ function xmldb_main_upgrade($oldversion) {
|
||||
$dbman->drop_field($table, $field);
|
||||
}
|
||||
|
||||
// Since structure of 'course' table has changed we need to re-read $SITE from DB.
|
||||
$SITE = $DB->get_record('course', array('id' => $SITE->id));
|
||||
$COURSE = clone($SITE);
|
||||
|
||||
// Main savepoint reached.
|
||||
upgrade_main_savepoint(true, 2013040300.01);
|
||||
}
|
||||
|
||||
+5
-1
@@ -1512,7 +1512,7 @@ function install_core($version, $verbose) {
|
||||
* @return void, may throw exception
|
||||
*/
|
||||
function upgrade_core($version, $verbose) {
|
||||
global $CFG;
|
||||
global $CFG, $SITE, $DB, $COURSE;
|
||||
|
||||
raise_memory_limit(MEMORY_EXTRA);
|
||||
|
||||
@@ -1543,6 +1543,10 @@ function upgrade_core($version, $verbose) {
|
||||
upgrade_main_savepoint($result, $version, false);
|
||||
}
|
||||
|
||||
// In case structure of 'course' table has been changed and we forgot to update $SITE, re-read it from db.
|
||||
$SITE = $DB->get_record('course', array('id' => $SITE->id));
|
||||
$COURSE = clone($SITE);
|
||||
|
||||
// perform all other component upgrade routines
|
||||
update_capabilities('moodle');
|
||||
log_update_descriptions('moodle');
|
||||
|
||||
Reference in New Issue
Block a user