Undefined index error when using WP-CLI (command line)
-
Hi,
I get an undefined index error when using WP-CLI – however I suspect this will be the same for all command-line usage of WordPress. This is because $_SERVER[‘QUERY_STRING’] is not set when using WordPress via the command line.
Here’s an example from WP-CLI which shows the error:
root@7cfe97bb15e9:/bedrock# wp post list PHP Notice: Undefined index: QUERY_STRING in /bedrock/web/app/plugins/stop-user-enumeration/stop-user-enumeration.php on line 36 Notice: Undefined index: QUERY_STRING in /bedrock/web/app/plugins/stop-user-enumeration/stop-user-enumeration.php on line 36 +----+------------------------+------------------------+---------------------+-------------+ | ID | post_title | post_name | post_date | post_status | +----+------------------------+------------------------+---------------------+-------------+ | 1 | Hello world! | hello-world | 2016-02-15 12:27:08 | publish | +----+------------------------+------------------------+---------------------+-------------+
Could you please add an isset() check before using the QUERY_STRING variable?
Thanks
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Undefined index error when using WP-CLI (command line)’ is closed to new replies.