MDL-79527 questions: category tree loading handling bad data
commit049bff63bc119112efef286367c742126e29c957
authorTim Hunt <T.J.Hunt@open.ac.uk>
Mon, 11 Dec 2023 19:11:45 +0000 (11 19:11 +0000)
committerTim Hunt <T.J.Hunt@open.ac.uk>
Fri, 2 Feb 2024 11:26:57 +0000 (2 11:26 +0000)
treec5a27caf80d8eddcd235fe53f4afa60af778c63d
parent3fc907e3d8646d53b744cbeb2820f5a060cc86ee
MDL-79527 questions: category tree loading handling bad data

It should always be the case that a question category and its parent
category belong to the same context. However, over the years, we have
observed that this becomes violated by some data in some Moodle sites.
(The suspicion is that this is a backup/restor bug of some sort which
has never been tracked down.)

Since this happens, we should make the code robust to it, which is what
this change does. It ensure that when loading child categories, we only
consider ones in the same context.
lib/questionlib.php
lib/tests/questionlib_test.php
question/tests/generator/lib.php