• Resolved colinhrt

    (@colinhrt)


    Hello

    I am running the latest WordPress on Apache 2.4 with PHP 8.1. I had the wordpress wp-cron.php file being called by a wget run by the host servers cron, with ‘DISABLE_WP_CRON’ set true in the wp-config.php file, this was working fine.

    I then decided to run the wp-cron.php directly from the servers cron file with a line like ‘cd /var/www/site.tld/www; php /var/www/site.tld/www/wp-cron.php’ This runs the wp-cron.php but now I get a warning every time it runs

    PHP Warning: Undefined array key “REQUEST_METHOD” in /var/www/site.tld/www/wp-content/plugins/pretty-link/app/controllers/PrliAppController.php on line 33

    I guess this is something to do with not calling it via a http request, and running wp-cron.php like this is something of an edge case. Whilst this Warning is not a problem as such it is an irritation and puts unnecessary noise in the log files.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Use PHP 8.0! Most plugins, themes and WordPress itself isn’t ready yet for PHP 8.1. It is good to ask for support but I suggest also run your website on local and check every month with Query Monitor plugin if your website doesn’t throw error when using Php 8.1. If you don’t see any error or warnings then move to Php 8.1!!

    Thread Starter colinhrt

    (@colinhrt)

    I just tried installing PHP 8.0.

    PHP 8.0.26 (cli) (built: Dec 5 2022 21:59:43) ( NTS )
    Copyright (c) The PHP Group
    Zend Engine v4.0.26, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.26, Copyright (c), by Zend Technologies

    And I see the same warning when running this, it does like when being run from the command line the PrettyLinks plugin is not handling the missing REQUEST_HEADER variable nicely.

    Thread Starter colinhrt

    (@colinhrt)

    I have just tried this with PHP 7.4

    PHP 7.4.33 (cli) (built: Nov 8 2022 11:36:34) ( NTS )
    Copyright (c) The PHP Group
    Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.33, Copyright (c), by Zend Technologies

    And there is no warning then, so it seems it is something that came in with PHP 8.0, possibly PHP 8.0 is being more strict or something.

    Tyler

    (@tylerthedude)

    Hi Colin,

    This warning is something that our development team is aware of and are hoping to get fixed soon. In the meantime, you should be able to prevent that notice from occurring by editing the PrliAppController.php file located under wp-content/plugins/pretty-link/controllers/ and then on line 33 replace this line:
    if($_SERVER["REQUEST_METHOD"] == 'GET' && !is_admin()) {

    With this line:
    if(isset($_SERVER['REQUEST_METHOD']) && $_SERVER["REQUEST_METHOD"] == 'GET' && !is_admin()) {

    Kind regards,

    Tyler

    (@tylerthedude)

    Hi Colin,

    I just wanted to follow up on this thread and let you know that we’ve released a new version of Pretty Links that includes a fix for this warning, so if you haven’t already please upgrade to this version (3.3.0) and the warning will no longer be logged going forward.

    Kind regards,

    Thread Starter colinhrt

    (@colinhrt)

    Thank you for that. I have tried the WordPress Cron job on PHP 7.4, 8.0, 8.1, 8.2 with the updated Pretty Links Plugin installed and it works fine now with no warning messages.

    Regards

    Colin

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘PHP Warning: Undefined array key “REQUEST_METHOD”’ is closed to new replies.