page-cache
page-cache copied to clipboard
Undefined array key "QUERY_STRING"
On certain circumstances, in init() method a PHP warning is thrown:
Warning: Undefined array key "QUERY_STRING" in path/to/vendor/mmamedov/page-cache/src/PageCache.php on line 133
It seems $_SERVER['QUERY_STRING']
may not be set sometimes (for me: PHP 8 on localhost/internal webserver). This causes PHP to generate a warning, when the init() method calls the log method – passing URI, script name and query string.
According to the Manual [1], one indeed ”may or may not find any of the elements in $_SERVER
”. So my proposal is to introduce a check if $_SERVER
fields are set. If a PR is welcome, I'll happily send one around.
[1] https://www.php.net/manual/en/reserved.variables.server.php