-
Bug
-
Resolution: Fixed
-
Minor
-
3.9.4, 3.10.1
-
MOODLE_310_STABLE, MOODLE_39_STABLE
-
MOODLE_310_STABLE, MOODLE_39_STABLE
-
It seems that, in our database, we have some course_modules, and contexts, which exist, but the corresponding course does not exist any more.
In this case, context.path is null, and this causes the DB queries in tool_capability_calculate_role_data to throw an exception like:
Debug info: ERROR: invalid input syntax for integer: ""
|
|
SELECT ctx.*
|
FROM mdl_context ctx
|
LEFT JOIN mdl_user u ON ctx.contextlevel = 30 AND u.id = ctx.instanceid
|
LEFT JOIN mdl_course_categories cat ON ctx.contextlevel = 40 AND cat.id = ctx.instanceid
|
LEFT JOIN mdl_course c ON ctx.contextlevel = 50 AND c.id = ctx.instanceid
|
LEFT JOIN mdl_course_modules cm ON ctx.contextlevel = 70 AND cm.id = ctx.instanceid
|
LEFT JOIN mdl_block_instances bi ON ctx.contextlevel = 80 AND bi.id = ctx.instanceid
|
WHERE ctx.id IN ($1,$2)
|
ORDER BY ctx.contextlevel, bi.defaultregion, COALESCE(cat.sortorder, c.sortorder, cm.section, bi.defaultweight), u.lastname, u.firstname, cm.id
|
|
[array (
|
0 => 1,
|
2 => '',
|
)]
|
Error code: dmlreadexception
|
×Stack trace:
|
line 486 of /lib/dml/moodle_database.php: dml_read_exception thrown
|
line 329 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
|
line 932 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
|
line 7694 of /lib/accesslib.php: call to pgsql_native_moodle_database->get_records_sql()
|
line 66 of /admin/tool/capability/locallib.php: call to get_sorted_contexts()
|
line 100 of /admin/tool/capability/renderer.php: call to tool_capability_calculate_role_data()
|
line 111 of /admin/tool/capability/index.php: call to tool_capability_renderer->capability_comparison_table()
|
Of course, there should not be orphan contexts, but given that it can happen, I think we need to change this report to be robust to the problem.