Describe the bug
Moodle 4.4.1: When editing a course that has less sections specified in the settings than there are on the course page (giving "Orphaned Sections") Moodle will give a "function course_section_add_cm_control() " error when editing the course.
To Reproduce
Steps to reproduce the behaviour:
Create a course, using Collapsed Topics format, with 5 sections.
Put a document into sections 1, 2 and 5.
From course settings reduce the number of sections to 3
Turn editing on (if not already)
"Exception - Call to a member function course_section_add_cm_control() on null"
Increasing the number of sections (to 5 or more) will allow editing again.
Expected behaviour
Sections with content that are above the number defined in the course settings are displayed as "Orphaned" when editing, but the content is still available. E.g. in Moodle 4.1
Versions (please complete the following information):
Moodle: [4.4.1]
Format: [404.0.2]
Browser and version [Chrome Version 126.0.6478.127 (Official Build) (64-bit) on Windows 11 (also happens on Windows 10) and on Edge Version 126.0.2592.68 (Official build) (64-bit)]
Additional context
Switching editing off gives access to the 3 sections as specified in settings, but unable to edit without error.
Same behaviour when importing content from a course with more sections than the one you are importing into.
Describe the bug Moodle 4.4.1: When editing a course that has less sections specified in the settings than there are on the course page (giving "Orphaned Sections") Moodle will give a "function course_section_add_cm_control() " error when editing the course.
To Reproduce Steps to reproduce the behaviour:
Expected behaviour Sections with content that are above the number defined in the course settings are displayed as "Orphaned" when editing, but the content is still available. E.g. in Moodle 4.1
Versions (please complete the following information):
Additional context