-
Bug
-
Resolution: Fixed
-
Minor
-
4.4
-
MOODLE_404_STABLE
-
MOODLE_404_STABLE
-
MDL-81446-main -
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.