MDL-42772 upgrade: Force alternate fields in session user

This commit is contained in:
Frederic Massart
2013-11-08 14:01:39 +08:00
parent d25e988d08
commit 4bceea11be
2 changed files with 17 additions and 1 deletions
+16
View File
@@ -2831,5 +2831,21 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2013110600.01);
}
if ($oldversion < 2013110600.02) {
// If the user is logged in, we ensure that the alternate name fields are present
// in the session. It will not be the case when upgrading from 2.5 downwards.
if (!empty($USER->id)) {
$refreshuser = $DB->get_record('user', array('id' => $USER->id));
$fields = array('firstnamephonetic', 'lastnamephonetic', 'middlename', 'alternatename', 'firstname', 'lastname');
foreach ($fields as $field) {
$USER->{$field} = $refreshuser->{$field};
}
}
// Main savepoint reached.
upgrade_main_savepoint(true, 2013110600.02);
}
return true;
}
+1 -1
View File
@@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2013110600.01; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2013110600.02; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.