MDL-77953 pagelib: Ensure that null $SCRIPT continues behaving the same
It's possible to have some Moodle components soft linked instead of being real directories within codebase (within dirroot). For example, Composer's "vendor" directory can be soft linked (from elsewhere), or also plugins can be installed using soft links. In those cases, Moodle calculates the $SCRIPT global as null. And, then, string operations on it are emitting a PHP deprecation message with PHP 8.1 and up. This fix just ensures that the behaviour is the same than before PHP 8.1, aka: ltrim(null) = '' (empty string), without any PHP warning.
This commit is contained in:
+1
-1
@@ -1873,7 +1873,7 @@ class moodle_page {
|
||||
}
|
||||
|
||||
if (is_null($script)) {
|
||||
$script = ltrim($SCRIPT, '/');
|
||||
$script = ltrim($SCRIPT ?? '', '/');
|
||||
$len = strlen($CFG->admin);
|
||||
if (substr($script, 0, $len) == $CFG->admin) {
|
||||
$script = 'admin' . substr($script, $len);
|
||||
|
||||
Reference in New Issue
Block a user