Affects Version/s: 3.7
Fix Version/s: None
In mod/forum/lib.php function forum_get_readable_forums($userid, $courseid=0) is almost inevitably called with $courseid set, and therefore the else in the following test is not called.
If the test were to be called with $courseid==0 this would result in an error because modinfo no longer exists in mdl_course.
The fault can simply be remove with
$courses2 = enrol_get_users_courses($userid, true);
because the true modinfo is collected after this test.
However may I suggest that the test itself not be removed because it is in fact very useful! I hit the field error when intentionally calling the above function with:
$forums = forum_get_readable_forums($USER->id, 0);
from, function forum_search_posts(...).
With array('modinfo') removed, this call returns ALL the forums in ALL the courses to which the current user has access. In the case of a very small site with limited numbers of courses, or perhaps with single-activity courses, this behaviour can be very useful. In fact in such a forum-only course, the title "Search forums" on the quick search is a misnomer currently.
Naturally an admin setting that allows this global search behaviour to be turned on if desired would be the obvious solution.
To complete the picture this would also imply the need to see ALL forums in the dropdown within advanced search, using a function
If others found this functionality useful, then again it could be controlled by the same admin setting.
Many thanks, John White