Skip to content

Commit

Permalink
Fix a bunch of deprecation warnings
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mrzool committed Apr 10, 2022
1 parent ab563be commit b0a6a9a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit b0a6a9a

Please sign in to comment.