MDL-74269 course: Make sure category exists before updating

This commit is contained in:
Eric Merrill
2022-03-18 15:30:19 -04:00
parent 0d0f09bc7f
commit dd5406527a
+1 -1
View File
@@ -2764,7 +2764,7 @@ function xmldb_main_upgrade($oldversion) {
// Set the description field to HTML format for the Default course category.
$category = $DB->get_record('course_categories', ['id' => 1]);
if ($category->descriptionformat == FORMAT_MOODLE) {
if (!empty($category) && $category->descriptionformat == FORMAT_MOODLE) {
// Format should be changed only if it's still set to FORMAT_MOODLE.
if (!is_null($category->description)) {
// If description is not empty, format the content to HTML.