mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
Merge branch 'MDL-72950_311' of https://github.com/stronk7/moodle into MOODLE_311_STABLE
This commit is contained in:
commit
5cb47da3f1
2 changed files with 16 additions and 8 deletions
|
@ -619,7 +619,8 @@ abstract class restore_dbops {
|
||||||
// Top-level category counter.
|
// Top-level category counter.
|
||||||
$topcats = 0;
|
$topcats = 0;
|
||||||
// get categories in context (bank)
|
// get categories in context (bank)
|
||||||
$categories = self::restore_get_question_categories($restoreid, $contextid);
|
$categories = self::restore_get_question_categories($restoreid, $contextid, $contextlevel);
|
||||||
|
|
||||||
// cache permissions if $targetcontext is found
|
// cache permissions if $targetcontext is found
|
||||||
if ($targetcontext = self::restore_find_best_target_context($categories, $courseid, $contextlevel)) {
|
if ($targetcontext = self::restore_find_best_target_context($categories, $courseid, $contextlevel)) {
|
||||||
$canmanagecategory = has_capability('moodle/question:managecategory', $targetcontext, $userid);
|
$canmanagecategory = has_capability('moodle/question:managecategory', $targetcontext, $userid);
|
||||||
|
@ -765,8 +766,13 @@ abstract class restore_dbops {
|
||||||
/**
|
/**
|
||||||
* Return one array of question_category records for
|
* Return one array of question_category records for
|
||||||
* a given restore operation and one restore context (question bank)
|
* a given restore operation and one restore context (question bank)
|
||||||
|
*
|
||||||
|
* @param string $restoreid Unique identifier of the restore operation being performed.
|
||||||
|
* @param int $contextid Context id we want question categories to be returned.
|
||||||
|
* @param int $contextlevel Context level we want to restrict the returned categories.
|
||||||
|
* @return array Question categories for the given context id and level.
|
||||||
*/
|
*/
|
||||||
public static function restore_get_question_categories($restoreid, $contextid) {
|
public static function restore_get_question_categories($restoreid, $contextid, $contextlevel) {
|
||||||
global $DB;
|
global $DB;
|
||||||
|
|
||||||
$results = array();
|
$results = array();
|
||||||
|
@ -776,7 +782,14 @@ abstract class restore_dbops {
|
||||||
AND itemname = 'question_category'
|
AND itemname = 'question_category'
|
||||||
AND parentitemid = ?", array($restoreid, $contextid));
|
AND parentitemid = ?", array($restoreid, $contextid));
|
||||||
foreach ($qcats as $qcat) {
|
foreach ($qcats as $qcat) {
|
||||||
$results[$qcat->itemid] = backup_controller_dbops::decode_backup_temp_info($qcat->info);
|
$result = backup_controller_dbops::decode_backup_temp_info($qcat->info);
|
||||||
|
// Filter out found categories that belong to another context level.
|
||||||
|
// (this can happen when a higher level category becomes remapped to
|
||||||
|
// a context id that, by coincidence, matches a context id of another
|
||||||
|
// category at lower level). See MDL-72950 for more info.
|
||||||
|
if ($result->contextlevel == $contextlevel) {
|
||||||
|
$results[$qcat->itemid] = $result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$qcats->close();
|
$qcats->close();
|
||||||
|
|
||||||
|
|
|
@ -47,11 +47,6 @@ class restore_attempt_test extends \advanced_testcase {
|
||||||
public function test_restore_question_attempts_missing_users(): void {
|
public function test_restore_question_attempts_missing_users(): void {
|
||||||
global $DB, $USER;
|
global $DB, $USER;
|
||||||
|
|
||||||
// TODO: Remove this once MDL-72950 is fixed.
|
|
||||||
if ($DB->get_dbfamily() == 'oracle') {
|
|
||||||
$this->markTestSkipped("Skipping for Oracle until MDL-72950 is fixed.");
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->resetAfterTest();
|
$this->resetAfterTest();
|
||||||
$this->setAdminUser();
|
$this->setAdminUser();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue