PHP Notice: Undefined index: REQUEST_METHOD
🐞 bug report
Behavior:
A customer reported that the PHP log file contains a large amount of notices indicating that $_SERVER['REQUEST_METHOD'] is missing. This seems to occur in customer's specific environment, which includes some optimisations that might result in a "not completely standard" environment.
The notice is the following (redacted for brevity):
PHP Notice: Undefined index: REQUEST_METHOD in /path/to/freemius/wordpress-sdk/config.php on line 166
Affected line: https://github.com/Freemius/wordpress-sdk/blob/84a9be4717effd7697a217e0d931f48ae0d2ecc6/config.php#L166
Possible solution
Adding a check to verify that the expected header is set should be sufficient. The code around the affected line already do that, using isset(). Examples:
https://github.com/Freemius/wordpress-sdk/blob/84a9be4717effd7697a217e0d931f48ae0d2ecc6/config.php#L155
https://github.com/Freemius/wordpress-sdk/blob/84a9be4717effd7697a217e0d931f48ae0d2ecc6/config.php#L159
https://github.com/Freemius/wordpress-sdk/blob/84a9be4717effd7697a217e0d931f48ae0d2ecc6/config.php#L160
Versions: (*)
-
Freemius SDK Version:2.4.2 -
WordPress Version:unknown, possibly 5.7 or 5.8 -
PHP Version:unknown, possibly 7.4.x
Plugin / Theme: (*)
-
Name:Aelia Blacklister for WooCommerce -
Freemius ID:8438
Note The plugin itself is not relevant, in this case. The Blacklister is not yet distributed via Freemius, but the framework is loaded anyway, as part of the autoloading mechanism in our solutions.