-
Bug
-
Resolution: Fixed
-
Major
-
3.9.14, 3.9.15, 3.10.11, 3.11.7, 3.11.10, 4.0.1, 4.0.4
-
MOODLE_310_STABLE, MOODLE_311_STABLE, MOODLE_39_STABLE, MOODLE_400_STABLE
-
MOODLE_311_STABLE, MOODLE_400_STABLE
-
We noticed this as in cron \ core \ task \ tag_cron_task it breaks for a missing context.
This is the message: "
Scheduled task failed: Elaborazione in background: tag (core\task\tag_cron_task),Non è possibile trovare il record nella tabella context. (SELECT * FROM {context} WHERE id = ?
[array (
0 => '2264205',
)])
Debug info:
SELECT * FROM {context} WHERE id = ?
[array (
0 => '2264205',
)]
Backtrace:
- line 1622 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
- line 5353 of /lib/accesslib.php: call to moodle_database->get_record()
- line 221 of /lib/classes/event/base.php: call to context::instance_by_id()
- line 96 of /lib/classes/event/tag_removed.php: call to core\event\base::create()
- line 268 of /lib/classes/task/tag_cron_task.php: call to core\event\tag_removed::create_from_tag_instance()
- line 209 of /lib/classes/task/tag_cron_task.php: call to core\task\tag_cron_task->bulk_delete_instances()
- line 51 of /lib/classes/task/tag_cron_task.php: call to core\task\tag_cron_task->cleanup()
- line 253 of /lib/cronlib.php: call to core\task\tag_cron_task->execute()
- line 167 of /admin/cli/scheduled_task.php: call to cron_run_inner_scheduled_task()
"
We have therefore realized that the primitive delete_course does not delete the instances tag of the activities but only deletes the tags at the course level.
The cron is consequently broken because the instances tag of the activities no longer have context.
To realize this, just:
1. create a course
2. create any activity
3. add a tag
4. cancel the course
5. execute the following query on db: "SELECT ti.id FROM mdl_tag_instance ti left join mdl_context c on c.id = ti.contextid where c.id is null order by ti.id ASC "
6. the result shows the context orphaned instances tags. If it helps I have seen that there is a primitive course_delete_module that also deletes the instances tag at the activity level by calling the function: "core_tag_tag :: remove_all_item_tags ('core', 'course_modules', $ cm-> id);"
- Discovered while testing
-
MDL-75245 Create "Tags" custom report source
- Closed