-
Bug
-
Resolution: Fixed
-
Minor
-
4.1.17, 4.3.11, 4.4.7, 4.5.3
-
2
We have below regex in Moodle backup code to clean the CTRL characters
/[\x-\x8\xb-\xc\xe-\x1f\x7f]/is
|
But in PHP (PCRE), \x is used to define hexadecimal escape sequences (e.g.: \x00 for NUL), and \x- is incorrect since - is not a valid hexadecimal digit.
This broke the backup/restore process in Moodle with the latest PHP versions. Example: 8.2.28 and 8.3.19
They might include PCRE library version: 10.45 2025-02-05. This PCRE introduces a breaking change:
https://github.com/PCRE2Project/pcre2/blob/master/ChangeLog#L119
We can see the error by running
vendor/bin/phpunit --filter test_restore_controller_is_executing
|
Error
1) core_backup\controller_test::test_restore_controller_is_executing |
restore_controller_exception: error/restore_unknown_restore_type
|
$a contents:
|
I used XDebug and PPHPUnit to find out the root cause, below is the extra error
preg_replace(): Compilation failed: digits missing after \x or in \x{} or \o{} or \N{U+} at offset 3 |