Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-39099

Course format protected function cannot be overridden because of private call.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 2.3.6, 2.4.3
    • 2.3.6, 2.4.3, 2.5
    • Course
    • MOODLE_23_STABLE, MOODLE_24_STABLE, MOODLE_25_STABLE
    • MOODLE_23_STABLE, MOODLE_24_STABLE
    • wip-MDL-39099_master
    • Hide

      Create a new version of 'section_activity_summary()' in the sibling class and have the overridden 'section_summary()' call it instead. But this is substantial duplicated code and the patch is a one word fix.

      Show
      Create a new version of 'section_activity_summary()' in the sibling class and have the overridden 'section_summary()' call it instead. But this is substantial duplicated code and the patch is a one word fix.
    • Hide

      1. Turn on 'Developer' level debugging.
      2. Create a 'Topics' based course with the 'Course layout' formatting option set to 'Show one section per page'.
      3. Copy the method 'section_summary()' contained within '/course/format/renderer.php' and place it within the 'format_topics_renderer' class of '/course/format/topics/renderer.php'.
      4. Go to the course you created.
      5. Observe the error message 'Coding error detected, it must be fixed by a programmer: Unknown method called against format_topics_renderer :: section_activity_summary' displayed.
      6. Apply the patch.
      7. Go back to the course you created, observe that the error message is not displayed and the course renders.
      8. If required, revert the file '/course/format/topics/renderer.php' such that the test code is not integrated.

      Show
      1. Turn on 'Developer' level debugging. 2. Create a 'Topics' based course with the 'Course layout' formatting option set to 'Show one section per page'. 3. Copy the method 'section_summary()' contained within '/course/format/renderer.php' and place it within the 'format_topics_renderer' class of '/course/format/topics/renderer.php'. 4. Go to the course you created. 5. Observe the error message 'Coding error detected, it must be fixed by a programmer: Unknown method called against format_topics_renderer :: section_activity_summary' displayed. 6. Apply the patch. 7. Go back to the course you created, observe that the error message is not displayed and the course renders. 8. If required, revert the file '/course/format/topics/renderer.php' such that the test code is not integrated.

      In '/course/format/renderer.php', there is a method which calls a private method:

      protected function section_summary($section, $course, $mods) {
      ...
      $o.= $this->section_activity_summary($section, $course, null);
      

      but because 'section_activity_summary()' is defined as 'private':

      private function section_activity_summary($section, $course, $mods)
      

      a sibling class cannot override the protected method 'section_summary()' say to alter the way the classes are applied to the 'li' tag without resulting in the error:

      Coding error detected, it must be fixed by a programmer: Unknown method called against format_topcoll_renderer :: section_activity_summary

      Therefore 'section_activity_summary()' needs to be changed to:

      protected function section_activity_summary($section, $course, $mods)
      

      To allow the overridden protected method 'section_summary' to call it.

            gb2048 Gareth J Barnard
            gb2048 Gareth J Barnard
            Dan Poltawski Dan Poltawski
            Sam Hemelryk Sam Hemelryk
            Rossiani Wijaya Rossiani Wijaya
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.