Affects Version/s: 3.4.7, 3.5.4, 3.6.2
Fix Version/s: None
Affected Branches:MOODLE_34_STABLE, MOODLE_35_STABLE, MOODLE_36_STABLE
When a user is enrolled in more courses than $CFG->navcourselimit, some of those courses will display 'Courses' (linking to /course/index.php) instead of 'My Courses'
Be logged in as a user who is enrolled in more courses that the navcourselimit. Navigate to the user's profile.
All the courses that display initially will work as expected, but all of the courses revealed by clicking the 'View More' link will display the error.
I tracked the issue through the source code, and it seems to be an issue between these methods in /lib/navigationlib.php:
Initialise calls load_courses_enrolled first, and then add_course second for the course page we are currently in. The fundamental issue is that add_course assumes that all courses that belong in mycourses must have allready been loaded into rootnodes['mycourses'] by load_courses_enrolled.
One simple fix would be to not assume that rootnode['mycourses'] does not have every course you are enrolled in and just check.