From b0a6a9a60b0e5760401518e5c7376b6aa9870331 Mon Sep 17 00:00:00 2001 From: Mattia Tezzele Date: Sun, 10 Apr 2022 11:31:07 +0200 Subject: [PATCH] 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 --- index.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/index.php b/index.php index c5d97b8..e1313ac 100644 --- a/index.php +++ b/index.php @@ -214,6 +214,14 @@ function file_put_contents($n, $d) } } } +// Support PHP 8.1 by setting two predefined variables to empty strings if +// not already defined. Fixes a bunch of deprecation warnings. + +if (!isset($_SERVER["PATH_INFO"])) + $_SERVER["PATH_INFO"] = ''; +if (!isset($_REQUEST['page'])) + $_REQUEST['page'] = ''; + // Main code