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

get_plugins_with_function needs to check if function exists

    XMLWordPrintable

Details

    • 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.

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

              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

              Dates

                Created:
                Updated:
                Resolved:
                18/Jan/21

                Time Tracking

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