page-cache icon indicating copy to clipboard operation
page-cache copied to clipboard

Undefined array key "QUERY_STRING"

Open tomkyle opened this issue 3 years ago • 0 comments

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

tomkyle avatar Feb 17 '21 06:02 tomkyle