Skip to content

Commit b0a6a9a

Browse files
committed
Fix a bunch of deprecation warnings
By setting $_SERVER["PATH_INFO"] and $_REQUEST['page'] to empty strings if they are not already defined. This is to avoid passing `null` to `preg_match()` and `str_replace()` (used in `sanitizeFilename()`), since this is deprecated in PHP 8.1. This approach is recommended here: https://php.watch/versions/8.1/internal-func-non-nullable-null-deprecation
1 parent ab563be commit b0a6a9a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

index.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,14 @@ function file_put_contents($n, $d)
214214
}
215215
}
216216
}
217+
// Support PHP 8.1 by setting two predefined variables to empty strings if
218+
// not already defined. Fixes a bunch of deprecation warnings.
219+
220+
if (!isset($_SERVER["PATH_INFO"]))
221+
$_SERVER["PATH_INFO"] = '';
222+
if (!isset($_REQUEST['page']))
223+
$_REQUEST['page'] = '';
224+
217225

218226
// Main code
219227

0 commit comments

Comments
 (0)