backup/restore: MDL-16614 more reliable test for when we are restoring a backup that was made of the same site that we are restoring to.
* Use this to fix a question restore bug. * Replace older code that does something similar with the new test. * Refactor initialisation of $CFG->siteidentifier into a function. There were about 4 copies of this code ;-)
This commit is contained in:
+22
-2
@@ -334,8 +334,28 @@
|
||||
$question->hidden = backup_todb($que_info['#']['HIDDEN']['0']['#']);
|
||||
$question->timecreated = backup_todb_optional_field($que_info, 'TIMECREATED', 0);
|
||||
$question->timemodified = backup_todb_optional_field($que_info, 'TIMEMODIFIED', 0);
|
||||
$question->createdby = backup_todb_optional_field($que_info, 'CREATEDBY', null);
|
||||
$question->modifiedby = backup_todb_optional_field($que_info, 'MODIFIEDBY', null);
|
||||
|
||||
// Set the createdby field, if the user was in the backup, or if we are on the same site.
|
||||
$createdby = backup_todb_optional_field($que_info, 'CREATEDBY', null);
|
||||
if (!empty($createdby)) {
|
||||
$user = backup_getid($restore->backup_unique_code, 'user', $createdby);
|
||||
if ($user) {
|
||||
$question->createdby = $user->new_id;
|
||||
} else if (backup_is_same_site($restore)) {
|
||||
$question->createdby = $createdby;
|
||||
}
|
||||
}
|
||||
|
||||
// Set the modifiedby field, if the user was in the backup, or if we are on the same site.
|
||||
$modifiedby = backup_todb_optional_field($que_info, 'MODIFIEDBY', null);
|
||||
if (!empty($createdby)) {
|
||||
$user = backup_getid($restore->backup_unique_code, 'user', $modifiedby);
|
||||
if ($user) {
|
||||
$question->modifiedby = $user->new_id;
|
||||
} else if (backup_is_same_site($restore)) {
|
||||
$question->modifiedby = $modifiedby;
|
||||
}
|
||||
}
|
||||
|
||||
if ($restore->backup_version < 2006032200) {
|
||||
// The qtype was an integer that now needs to be converted to the name
|
||||
|
||||
Reference in New Issue
Block a user