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

get_plugins_with_function needs to check if function exists

XMLWordPrintable

    • MOODLE_310_STABLE, MOODLE_311_STABLE, MOODLE_38_STABLE, MOODLE_39_STABLE
    • MOODLE_310_STABLE, MOODLE_39_STABLE
    • MDL-70160-function-cache-m
    • Hide

      1) Edit admin/tool/usertours/lib.php and rename the tool_usertours_extend_navigation_users function to be incorrect: tool_usertourse_extend_navigation_user*z*

      2) Visit the dashboard, and verify the page loads with no errors.

      3) Undo the change to the function.

      4) Create a file called test.php in the root directory, and add the following content to it.

      <?php
      require_once('config.php');
      $functions = get_plugin_list_with_function('tool', 'extend_navigation_user');
      var_dump(array_key_exists('tool_usertours', $functions));

      5) Purge caches

      6) Visit the dashboard and let the page load.

      7) Change the name of the usertours function to be incorrect again: tool_usertours_extend_navigation_user*z*

      8) Visit the YOURSITE/test.php

      9) Verify you see false on the page. This shows that the function is no longer in the returned cached function list.

      Show
      1) Edit admin/tool/usertours/lib.php and rename the tool_usertours_extend_navigation_users function to be incorrect: tool_usertourse_extend_navigation_user*z* 2) Visit the dashboard, and verify the page loads with no errors. 3) Undo the change to the function. 4) Create a file called test.php in the root directory, and add the following content to it. <?php require_once( 'config.php' ); $functions = get_plugin_list_with_function( 'tool' , 'extend_navigation_user' ); var_dump(array_key_exists( 'tool_usertours' , $functions)); 5) Purge caches 6) Visit the dashboard and let the page load. 7) Change the name of the usertours function to be incorrect again: tool_usertours_extend_navigation_user*z* 8) Visit the YOURSITE/test.php 9) Verify you see false on the page. This shows that the function is no longer in the returned cached function list.

      When removing a callback function implementation inside a plugin, this can cause exceptions due to the function not being found. This can be solved easily by doing a cache purge, however this is unable to be performed from the frontend.

      The get_plugins_with_function method already checks for the presence of various other conditions, it should include a check for the function itself.

            peterburnett Peter Burnett
            peterburnett Peter Burnett
            Brendan Heywood Brendan Heywood
            Jake Dallimore Jake Dallimore
            Janelle Barcega Janelle Barcega
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

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

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