Describe the bug
The first time any search is run on the course search (/course/search.php), the site will crash with an exception. Subsequent calls will work, probably because the search results are cached - the error will come back after purging caches.
To Reproduce
Steps to reproduce the behavior:
Purge caches
Go to /course/search.php and search for something that will return at least one course
You will get this exception:
Exception - Argument 1 passed to course_modinfo::build_course_cache() must be an instance of stdClass, instance of core_course_list_element given, called in [dirroot]/lib/modinfolib.php on line 478
Debug info:
Error code: generalexceptionmessage×Dismiss this notification
Stack trace:
line 636 of /lib/modinfolib.php: TypeError thrown
line 478 of /lib/modinfolib.php: call to course_modinfo::build_course_cache()
line 436 of /lib/modinfolib.php: call to course_modinfo->__construct()
line 2532 of /lib/modinfolib.php: call to course_modinfo::instance()
line 1354 of /lib/completionlib.php: call to get_fast_modinfo()
line 73 of /completion/classes/progress.php: call to completion_info->get_activities()
line 172 of /theme/moove/classes/util/course.php: call to core_completion\progress::get_course_progress_percentage()
line 201 of /theme/moove/classes/output/core/course_renderer.php: call to theme_moove\util\course->get_progress()
line 172 of /theme/moove/classes/output/core/course_renderer.php: call to theme_moove\output\core\course_renderer->coursecat_coursebox_content()
line 118 of /theme/moove/classes/output/core/course_renderer.php: call to theme_moove\output\core\course_renderer->coursecat_coursebox()
line 1819 of /course/renderer.php: call to theme_moove\output\core\course_renderer->coursecat_courses()
line 111 of /course/search.php: call to core_course_renderer->search_courses()
Screenshots
Your environment (please complete the following information):
Describe the bug The first time any search is run on the course search (/course/search.php), the site will crash with an exception. Subsequent calls will work, probably because the search results are cached - the error will come back after purging caches.
To Reproduce Steps to reproduce the behavior:
You will get this exception: Exception - Argument 1 passed to course_modinfo::build_course_cache() must be an instance of stdClass, instance of core_course_list_element given, called in [dirroot]/lib/modinfolib.php on line 478
More information about this error
Debug info: Error code: generalexceptionmessage×Dismiss this notification Stack trace: line 636 of /lib/modinfolib.php: TypeError thrown line 478 of /lib/modinfolib.php: call to course_modinfo::build_course_cache() line 436 of /lib/modinfolib.php: call to course_modinfo->__construct() line 2532 of /lib/modinfolib.php: call to course_modinfo::instance() line 1354 of /lib/completionlib.php: call to get_fast_modinfo() line 73 of /completion/classes/progress.php: call to completion_info->get_activities() line 172 of /theme/moove/classes/util/course.php: call to core_completion\progress::get_course_progress_percentage() line 201 of /theme/moove/classes/output/core/course_renderer.php: call to theme_moove\util\course->get_progress() line 172 of /theme/moove/classes/output/core/course_renderer.php: call to theme_moove\output\core\course_renderer->coursecat_coursebox_content() line 118 of /theme/moove/classes/output/core/course_renderer.php: call to theme_moove\output\core\course_renderer->coursecat_coursebox() line 1819 of /course/renderer.php: call to theme_moove\output\core\course_renderer->coursecat_courses() line 111 of /course/search.php: call to core_course_renderer->search_courses()
Screenshots![image](https://user-images.githubusercontent.com/13886080/235873234-b7a99ebc-91a1-41b7-893a-c68505529647.png)
Your environment (please complete the following information):