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

Removing the after_config callback will make moodle unusable

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Minor
    • 3.8.2
    • 3.8
    • Administration
    • MOODLE_38_STABLE
    • MOODLE_38_STABLE
    • MDL-67680-master
    • Hide

      1. In any standard plugin in lib.php add the "after_config" callback. For example, add this code to blocks/online_users/lib.php :

      function block_online_users_after_config() {
          global $SITE;
          $SITE->fullname = 'hey';
      }
      

      2. Purge caches
      3. Open the site homepage and make sure that the site name is displayed as 'hey' now (you may need to refresh the page couple of times).
      4. Go back to the lib.php file you modified and instead of 'hey' write hey() (this will be a call to a non-existing function)

      $SITE->fullname = hey();
      

      5. Refresh the site homepage (may need several refreshes), and make sure that the normal site name is back and debugging message is displayed about an exception in callback. Before the patch your moodle site will be stuck on exception page here
      6. Remove the function completely
      7. Again, refresh the site homepage. Make sure there is a debugging message (it may be hidden under the menu bar) but site is still usable
      8. Purge caches
      9. Make sure site works as normal now without any debugging messages

      Show
      1. In any standard plugin in lib.php add the "after_config" callback. For example, add this code to blocks/online_users/lib.php : function block_online_users_after_config() { global $SITE; $SITE->fullname = 'hey'; } 2. Purge caches 3. Open the site homepage and make sure that the site name is displayed as 'hey' now (you may need to refresh the page couple of times). 4. Go back to the lib.php file you modified and instead of 'hey' write hey() (this will be a call to a non-existing function) $SITE->fullname = hey(); 5. Refresh the site homepage (may need several refreshes), and make sure that the normal site name is back and debugging message is displayed about an exception in callback. Before the patch your moodle site will be stuck on exception page here 6. Remove the function completely 7. Again, refresh the site homepage. Make sure there is a debugging message (it may be hidden under the menu bar) but site is still usable 8. Purge caches 9. Make sure site works as normal now without any debugging messages

    Description

      MDL-66340 introduced a very useful callback "after_config", really great idea!

      However I noticed one problem. If I remove the callback function from one of the plugins, moodle just stops working at all. Whatever I do I get an exception, including calls to purge caches or trying to upgrade, even from CLI:

      $ php admin/cli/purge_caches.php
      !!! Exception - Call to undefined function tool_certification_after_config() !!!
      

      The method get_plugins_with_function() uses cache to cache the list of available callbacks, removing a function implementing callback causes exception. This is usually ok because you can always clear caches. However setup.php is included before anything else.

      Attachments

        Issue Links

          Activity

            People

              marina Marina Glancy
              marina Marina Glancy
              Brendan Heywood Brendan Heywood
              Adrian Greeve Adrian Greeve
              Janelle Barcega Janelle Barcega
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                9/Mar/20

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 hour, 40 minutes
                  1h 40m