MDL-35768 MDL-36017 Avoid calling format_base::get_course() when not necessary
- If we want to check fields 'numsections' or 'hiddensections' call course_get_format()->get_format_options() - We still use extended course object in course/edit.php, update_course(), create_course(), and inside course formats
This commit is contained in:
@@ -1886,12 +1886,15 @@ class global_navigation extends navigation_node {
|
||||
global $CFG;
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
|
||||
$course = course_get_format($course)->get_course(); // retrieve all format options as well
|
||||
$modinfo = get_fast_modinfo($course);
|
||||
$sections = $modinfo->get_section_info_all();
|
||||
if (isset($course->numsections)) {
|
||||
$sections = array_slice($sections, 0, $course->numsections+1, true);
|
||||
|
||||
// For course formats using 'numsections' trim the sections list
|
||||
$courseformatoptions = course_get_format($course)->get_format_options();
|
||||
if (isset($courseformatoptions['numsections'])) {
|
||||
$sections = array_slice($sections, 0, $courseformatoptions['numsections']+1, true);
|
||||
}
|
||||
|
||||
$activities = array();
|
||||
|
||||
foreach ($sections as $key => $section) {
|
||||
|
||||
Reference in New Issue
Block a user