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

Unit test errors with core renderer hook tests when using legacy callbacks

XMLWordPrintable

      I've encountered an issue with a couple of core renderer hook tests when both a legacy callback and a new hook callback exist. So far I've seen it in core\core_renderer_test::test_before_standard_top_of_body_html_generation_hooked and core\core_renderer_test::test_before_footer_html_generation_hooked 

      Unexpected debugging() call detected.
      Debugging: Callback before_standard_top_of_body_html in example_plugin component should be migrated to new hook

      After some digging it appears to be related to phpunit_get_instance() being called in these tests, which sets up a new instance without the existing component callbacks. These tests then attempt to render a page but will show the debugging message because is_deprecating_hook_present() will always return false as the new callback isn't loaded here.

      My understanding is that the intention here was to allow plugins to have both the new hook callback and the legacy callback to support multiple versions of Moodle in the same branch, so I think it's something that should be addressed.

      To replicate:
      1. Install a plugin that has been updated to support Moodle 4.4 and has both a legacy callback and new hook callback for one of these hooks, for example https://moodle.org/plugins/auth_outage
      2. Confirm that no error message about the hook appears on any regular page.
      3. Run a core renderer unit test like test_before_standard_top_of_body_html_generation_hooked
      4. Confirm Unexpected debugging() call detected.

            dobedobedoh Andrew Lyons
            benjaminwalker Benjamin Walker
            Paul Holden Paul Holden
            Simey Lameze Simey Lameze
            Kim Jared Lucas Kim Jared Lucas
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours, 20 minutes
                2h 20m

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