1
0
mirror of https://github.com/moodle/moodle.git synced 2025-05-08 09:16:46 +02:00

Merge branch 'MDL-69751-master' of git://github.com/mihailges/moodle

This commit is contained in:
Jake Dallimore 2020-10-21 09:59:48 +08:00
commit 3d0f28ebb8
3 changed files with 43 additions and 2 deletions
course/classes/local/service
lib/db
version.php

@ -110,7 +110,12 @@ class content_item_service {
throw new \coding_exception('The guest user does not exist in the database.');
}
$favourites = $this->get_content_favourites(self::RECOMMENDATION_PREFIX, \context_user::instance($CFG->siteguest));
// Make sure the guest user context exists.
if (!$guestusercontext = \context_user::instance($CFG->siteguest, false)) {
throw new \coding_exception('The guest user context does not exist.');
}
$favourites = $this->get_content_favourites(self::RECOMMENDATION_PREFIX, $guestusercontext);
$recommendationcache->set($CFG->siteguest, $favourites);
return $favourites;

@ -2815,5 +2815,41 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2021052500.27);
}
if ($oldversion < 2021052500.29) {
// Get the current guest user which is also set as 'deleted'.
$guestuser = $DB->get_record('user', ['id' => $CFG->siteguest, 'deleted' => 1]);
// If there is a deleted guest user, reset the user to not be deleted and make sure the related
// user context exists.
if ($guestuser) {
$guestuser->deleted = 0;
$DB->update_record('user', $guestuser);
// Get the guest user context.
$guestusercontext = $DB->get_record('context',
['contextlevel' => CONTEXT_USER, 'instanceid' => $guestuser->id]);
// If the guest user context does not exist, create it.
if (!$guestusercontext) {
$record = new stdClass();
$record->contextlevel = CONTEXT_USER;
$record->instanceid = $guestuser->id;
$record->depth = 0;
// The path is not known before insert.
$record->path = null;
$record->locked = 0;
$record->id = $DB->insert_record('context', $record);
// Update the path.
$record->path = '/' . SYSCONTEXTID . '/' . $record->id;
$record->depth = substr_count($record->path, '/');
$DB->update_record('context', $record);
}
}
// Main savepoint reached.
upgrade_main_savepoint(true, 2021052500.29);
}
return true;
}

@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2021052500.28; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2021052500.29; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.
$release = '4.0dev (Build: 20201021)'; // Human-friendly version name