mirror of
https://github.com/moodle/moodle.git
synced 2025-04-20 07:56:06 +02:00
MDL-41384 upgrade: make sure to re-read $SITE from DB when course table is altered
This commit is contained in:
parent
183515da23
commit
e20497827d
@ -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');
|
||||
|
||||
@ -1334,6 +1346,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);
|
||||
}
|
||||
@ -1386,6 +1402,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);
|
||||
}
|
||||
@ -1501,6 +1521,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
|
||||
@ -1989,6 +2010,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);
|
||||
}
|
||||
@ -2376,6 +2401,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);
|
||||
|
||||
// Define field calendartype to be added to user.
|
||||
$table = new xmldb_table('user');
|
||||
$field = new xmldb_field('calendartype', XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, 'gregorian');
|
||||
@ -2400,6 +2429,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, 2013091000.02);
|
||||
}
|
||||
@ -2423,6 +2456,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, 2013091000.03);
|
||||
}
|
||||
|
@ -1503,7 +1503,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);
|
||||
|
||||
@ -1534,6 +1534,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');
|
||||
|
Loading…
x
Reference in New Issue
Block a user