-
Bug
-
Resolution: Fixed
-
Minor
-
3.8, 3.8.1
-
MOODLE_38_STABLE
-
MOODLE_38_STABLE
-
MDL-67773-master -
If tags are enabled site wide (site administration -> advanced features), but are disabled for courses (site administration -> appearance -> manage tags), and course settings are saved, you get a warning and notice because $data ->tags is undefined.
Steps to reproduce:
- Turn on debugging
- Go to Site administration -> Advanced features
- Make sure tags functionality is enabled
- Go to Site administration -> Appearance -> Manage tags
- In the tags area, find the Courses row and disable it
- Create a course and go to it
- Edit setting
- Save and display
Output:
Notice: Undefined property: stdClass::$tags in /var/www/html/course/lib.php on line 2570
|
|
Warning: array_values() expects parameter 1 to be array, null given in /var/www/html/course/lib.php on line 2570
|
|
Notice: Undefined property: stdClass::$tags in /var/www/html/course/lib.php on line 2571
|
Expected:
Not see a notice or warning when saving a course.
Related issue:
https://tracker.moodle.org/browse/MDL-66446
Looks like this was reported and partially fixed before. That fix added a check to the if statement in the code on line 2568 in course/lib.php for the site wide tags setting, but we are still missing a solution for the other way to disable course tags (setting under site administration -> appearance -> manage tags).
Potential solution:
Replace the check for tags being enabled on line 2568 of course/lib.php
} else if ($field == 'tags' && !empty($CFG->usetags)) { |
with
} else if ($field == 'tags' && isset($data->tags)) { |
or potentially add this check to the current line if the other part is still needed for something. Or maybe add something else so that it includes a check for the manage tags setting.
The reasoning behind this suggestion though is that further below in the same function (update_course), the part that actually updates the tags in the course is wrapped in a check for isset($data->tags). So it would make sense that the code checking if it should add tags to $updatedfields would also use the same criteria as the part that actually updates them.