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

If a new plugin's 'classes' directory is not readable, a confusing error message results

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. Uncompress the attached local_test.zip into your local/ directory
      2. Prevent the classes directory from being readable: chmod 0000 /path/to/local/test/classes
      3. Run moodle install/upgrade
      4. VERIFY: you do not get an error about current_language() and the plugin is installed

      Note: you'll have to give yourself permission back on that directory to delete it after the test:
      chmod 0644 classes/

      Show
      Uncompress the attached local_test.zip into your local/ directory Prevent the classes directory from being readable: chmod 0000 /path/to/local/test/classes Run moodle install/upgrade VERIFY: you do not get an error about current_language() and the plugin is installed Note: you'll have to give yourself permission back on that directory to delete it after the test: chmod 0644 classes/
    • Affected Branches:
      MOODLE_29_STABLE
    • Fixed Branches:
      MOODLE_28_STABLE, MOODLE_29_STABLE
    • Pull Master Branch:
      MDL-50788-master

      Description

      If you're installing a new plugin, and the plugin directory is readable, but the classes directory is not, a confusing fatal error results:

      ( ! ) Fatal error: Call to undefined function current_language() in /home/james/www/rl/moodle29/lib/setuplib.php on line 685
      Call Stack

      1. Time Memory Function Location
        1 0.0267 709480 default_exception_handler( ) ../setuplib.php:0
        2 0.0267 710128 get_exception_info( ) ../setuplib.php:347
        3 0.0268 715800 get_docs_url( ) ../setuplib.php:541

      Line 651 of /lib/classes/component.php throws an exception because it can't read the directory. The error handler fails because it's trying to use current_language(), which hasn't yet been loaded from moodlelib.

      This patch fixes the problem, but a check for moodlelib in the exception handler might be a more effective solution.

      diff --git a/lib/classes/component.php b/lib/classes/component.php
      index 519bbab..435ea8e 100644
      --- a/lib/classes/component.php
      +++ b/lib/classes/component.php
      @@ -644,7 +644,7 @@ $cache = '.var_export($cache, true).';
            * @param string $namespace
            */
           protected static function load_classes($component, $fulldir, $namespace = '') {
      -        if (!is_dir($fulldir)) {
      +        if (!is_dir($fulldir) || !is_readable($fulldir)) {
                   return;
               }
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              poltawski Dan Poltawski
              Reporter:
              jamesmcq24 James McQuillan
              Peer reviewer:
              Dan Marsden
              Integrator:
              Andrew Nicols
              Tester:
              Simey Lameze
              Participants:
              Component watchers:
              Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón
              Votes:
              2 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                9/Nov/15