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

Bump early PHP version check

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 4.4
    • 4.4
    • General
    • MOODLE_404_STABLE
    • MOODLE_404_STABLE
    • MDL-81446-main
    • Hide
      1. Using PHP 8.0, attempt to run any CLI script:

        /opt/homebrew/Cellar/php@8.0/8.0.30/bin/php admin/cli/upgrade.php
        Moodle 4.4 or later requires at least PHP 8.1 (currently using version 8.0.30).
        Some servers may have multiple PHP versions installed, are you using the correct executable?
        

        1. Confirm you get an error message telling you that your version of PHP is unsupported
      Show
      Using PHP 8.0 , attempt to run any CLI script: /opt/homebrew/Cellar/php@8.0/8.0.30/bin/php admin/cli/upgrade.php Moodle 4.4 or later requires at least PHP 8.1 (currently using version 8.0.30). Some servers may have multiple PHP versions installed, are you using the correct executable? Confirm you get an error message telling you that your version of PHP is unsupported

      At the moment if you try to upgrade from Moodle 4.1 and haven't correclty changed your PHP version you get a confusing error message which doesn't actually indicate the issue.

      The issue is that in 4.4 we make use of features that are only present in PHP 8.1, specifically enums. We make use of these features in core files which are part of the early bootstrap. These happen before we load libraries such cache.

      What this means is that when we try to load lib/classes/param.php, we get a fatal language error (because it doesn't understand enum param syntax, which leads us to the Moodle execption handler, which tries to load a string, which checks for the string in the cache, and the whole thing goes bang.

      See stacktrace below:

      ➜  m79683 git:(aeb4856435) php admin/cli/upgrade.php
      PHP Fatal error:  Uncaught Error: Class "cache" not found in /Users/nicols/Sites/moodles/m79683/moodle/lib/classes/string_manager_standard.php:83
      Stack trace:
      #0 /Users/nicols/Sites/moodles/m79683/moodle/lib/moodlelib.php(6873): core_string_manager_standard->__construct('/Users/nicols/S...', '/Users/nicols/S...', Array, Array)
      #1 /Users/nicols/Sites/moodles/m79683/moodle/lib/setuplib.php(605): get_string_manager()
      #2 /Users/nicols/Sites/moodles/m79683/moodle/lib/setuplib.php(439): get_exception_info(Object(ParseError))
      #3 [internal function]: default_exception_handler(Object(ParseError))
      #4 {main}
        thrown in /Users/nicols/Sites/moodles/m79683/moodle/lib/classes/string_manager_standard.php on line 83
       
      Fatal error: Uncaught Error: Class "cache" not found in /Users/nicols/Sites/moodles/m79683/moodle/lib/classes/string_manager_standard.php on line 83
       
      Error: Class "cache" not found in /Users/nicols/Sites/moodles/m79683/moodle/lib/classes/string_manager_standard.php on line 83
       
      Call Stack:
          0.1350   10162000   1. default_exception_handler($ex = class ParseError { protected $message = 'syntax error, unexpected identifier "param"'; private ${Error}string = ''; protected $code = 0; protected $file = '/Users/nicols/Sites/moodles/m79683/moodle/lib/classes/param.php'; protected $line = 35; private array ${Error}trace = [0 => [...], 1 => [...], 2 => [...]]; private ?Throwable ${Error}previous = NULL; public $xdebug_message = '\nParseError: syntax error, unexpected identifier "param" in /Users/nicols/Sites/moodles/m79683/moodle/lib/classes/param.php on line 35\n\nCall Stack:\n    0.0006     443336   1. {main}() /Users/nicols/Sites/moodles/m79683/moodle/admin/cli/upgrade.php:0\n    0.0008     448864   2. require(\'/Users/nicols/Sites/moodles/m79683/moodle/config.php\') /Users/nicols/Sites/moodles/m79683/moodle/admin/cli/upgrade.php:41\n    0.0020     571960   3. require_once(\'/Users/nicols/Sites/moodles/m79683/moodle/lib/setup.php\') /User'... }) /Users/nicols/Sites/moodles/m79683/moodle/lib/setuplib.php:0
          0.1350   10162000   2. get_exception_info($ex = class ParseError { protected $message = 'syntax error, unexpected identifier "param"'; private ${Error}string = ''; protected $code = 0; protected $file = '/Users/nicols/Sites/moodles/m79683/moodle/lib/classes/param.php'; protected $line = 35; private array ${Error}trace = [0 => [...], 1 => [...], 2 => [...]]; private ?Throwable ${Error}previous = NULL; public $xdebug_message = '\nParseError: syntax error, unexpected identifier "param" in /Users/nicols/Sites/moodles/m79683/moodle/lib/classes/param.php on line 35\n\nCall Stack:\n    0.0006     443336   1. {main}() /Users/nicols/Sites/moodles/m79683/moodle/admin/cli/upgrade.php:0\n    0.0008     448864   2. require(\'/Users/nicols/Sites/moodles/m79683/moodle/config.php\') /Users/nicols/Sites/moodles/m79683/moodle/admin/cli/upgrade.php:41\n    0.0020     571960   3. require_once(\'/Users/nicols/Sites/moodles/m79683/moodle/lib/setup.php\') /User'... }) /Users/nicols/Sites/moodles/m79683/moodle/lib/setuplib.php:439
          0.1350   10162848   3. get_string_manager($forcereload = ???) /Users/nicols/Sites/moodles/m79683/moodle/lib/setuplib.php:605
          0.1354   10269800   4. core_string_manager_standard->__construct($otherroot = '/Users/nicols/Sites/moodles/m79683/moodledata/lang', $localroot = '/Users/nicols/Sites/moodles/m79683/moodledata/lang', $translist = [], $transaliases = []) /Users/nicols/Sites/moodles/m79683/moodle/lib/moodlelib.php:6873
      

      We have a basic PHP version check for exactly this type of case, located in lib/setuplib.php. It was last updated for PHP 5.4 and Moodle 3.6. Time to bump it.

            dobedobedoh Andrew Lyons
            dobedobedoh Andrew Lyons
            Ilya Tregubov Ilya Tregubov
            Huong Nguyen Huong Nguyen
            Ron Carl Alfon Yu Ron Carl Alfon Yu
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 59 minutes
                59m

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