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

get_plugins_with_function needs to check if function exists

    XMLWordPrintable

    Details

    • Testing Instructions:
      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.
    • Affected Branches:
      MOODLE_310_STABLE, MOODLE_311_STABLE, MOODLE_38_STABLE, MOODLE_39_STABLE
    • Fixed Branches:
      MOODLE_310_STABLE, MOODLE_39_STABLE
    • Pull 3.8 Branch:
      MDL-70160-function-cache-38
    • Pull 3.9 Branch:
      MDL-70160-function-cache-39
    • Pull 3.10 Branch:
      MDL-70160-function-cache-310
    • Pull Master Branch:
      MDL-70160-function-cache-m

      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

              Assignee:
              peterburnett Peter Burnett
              Reporter:
              peterburnett Peter Burnett
              Peer reviewer:
              Brendan Heywood
              Integrator:
              Jake Dallimore
              Tester:
              Janelle Barcega
              Participants:
              Component watchers:
              Matteo Scaramuccia, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona)
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                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