-
Bug
-
Resolution: Fixed
-
Minor
-
4.1
The search subsystem maintains a static variable, $coursedeleting to track what courses are being deleted throughout the lifetime of a request. See core_search\manager::course_deleting_start and core_search\manager::course_deleting_finish
The method core_search\manager::context_deleted makes use of this variable to skip deleting contexts in situations where the whole course would be deleted anyway.
In normal circumstances, this is fine, even if course_deleting_finish never gets called, because the $coursedeleting variable only lives for the duration of the request. However, in PHPUnit tests, it can cause problems.
MDL-74993 introduced a test that deliberately sets up a situation where the delete_course function will throw an exception. This results in the situation where course_deleting_start is called, and course_deleting_finish is not. Meaning that for all later tests being run, the $coursedeleting variable is set.
This can result in the simpledb tests failing; because when it tests context deletion, sometimes the $coursedeleting variable prevents the context from being deleted (as the code assumes a course deletion will remove it).
To replicate (you may need to run this twice to get the situation where a course ID gets reused in multiple tests):
vendor/bin/phpunit --stop-on-failure --testsuite=core_testsuite,search_simpledb_testsuite --filter "modinfolib|simpledb"
|
This situation is quite unfortunate, it requires deep knowledge of the internals of both the core_search subsystem and Moodle's PHPUnit setup to figure out what's going on. And it would be easy for any future search plugins to experience the same sort of failure seen here.
- has a non-specific relationship to
-
MDL-71731 PHPUnit memory usage almost doubled recently (3.10dev)
- Closed
-
MDL-43835 Use unique sequence values on database reset to pick unit testing mistakes
- Closed
-
MDL-74993 Extend 'Invalid course module ID' exception to provide the actual id when deleting a course
- Closed