Skip to content

Undefined array key "QUERY_STRING" #22

Description

@tomkyle

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions