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

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

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3.6, 2.4.3, 2.5
    • Fix Version/s: 2.3.6, 2.4.3
    • Component/s: Course
    • Labels:
    • Testing Instructions:
      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.
    • Workaround:
      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.
    • Affected Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE, MOODLE_25_STABLE
    • Fixed Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      wip-MDL-39099_master

      Description

      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.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Votes:
                  0 Vote for this issue
                  Watchers:
                  6 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    18/Mar/13