Title: Error while executing wordpress cron
Last modified: January 15, 2023

---

# Error while executing wordpress cron

 *  Resolved [ingohaeck](https://wordpress.org/support/users/ingohaeck/)
 * (@ingohaeck)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/error-while-executing-wordpress-cron/)
 * got this error, when executing the wordpress cron job:
 *     ```wp-block-code
       PHP Warning: Undefined array key "REQUEST_METHOD" in /var/www/vhosts/gearscout.de/httpdocs/wp-content/advanced-cache.php on line 79
       PHP Warning: Undefined array key "REQUEST_METHOD" in /var/www/vhosts/gearscout.de/httpdocs/wp-content/plugins/wp-cloudflare-page-cache/wp-cloudflare-super-page-cache.php on line 567
       PHP Warning: Undefined array key "HTTP_HOST" in /var/www/vhosts/gearscout.de/httpdocs/wp-content/plugins/wp-cloudflare-page-cache/libs/html_cache.class.php on line 79
       ```
   

Viewing 12 replies - 1 through 12 (of 12 total)

 *  Plugin Contributor [iSaumya](https://wordpress.org/support/users/isaumya/)
 * (@isaumya)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/error-while-executing-wordpress-cron/#post-16376189)
 * Hi [@ingohaeck](https://wordpress.org/support/users/ingohaeck/),
   You need to 
   contact your host and ask them why `$_SERVER['REQUEST_METHOD']`, `$_SERVER['HTTP_HOST']`
   is not returning any values. These are server level global variables which are
   supposed to return values. Maybe your host has disabled them or something. Please
   ask them why the global server variable is not returning these values.
 *  Thread Starter [ingohaeck](https://wordpress.org/support/users/ingohaeck/)
 * (@ingohaeck)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/error-while-executing-wordpress-cron/#post-16377815)
 * The server is my own Plesk-Server.
 * I changed from PHP 8.0 to PHP 7.4 and the cronjob works without errors.
   It seems
   something has changed with PHP 8.FYI: please see this discussion:
 * [https://wordpress.org/support/topic/php-warning-undefined-array-key-request_method/](https://wordpress.org/support/topic/php-warning-undefined-array-key-request_method/)
 * **Example:**
   `if($_SERVER["REQUEST_METHOD"] == 'GET' && !is_admin()) {`
 * has to be replaced with this line:
   `if(isset($_SERVER['REQUEST_METHOD']) && $
   _SERVER["REQUEST_METHOD"] == 'GET' && !is_admin()) {`
 *  Plugin Contributor [iSaumya](https://wordpress.org/support/users/isaumya/)
 * (@isaumya)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/error-while-executing-wordpress-cron/#post-16377876)
 * Hi [@ingohaeck](https://wordpress.org/support/users/ingohaeck/),
   I will definitely
   look into the `isset()` part, but these server values are standard and used by
   the plugin. You should definately look into the fact why they are not available.
   Cause I’ve this plugin on many sites running PHP 8.0 and 8.1 and things are running
   smoothly without any issues.
 *  Plugin Contributor [iSaumya](https://wordpress.org/support/users/isaumya/)
 * (@isaumya)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/error-while-executing-wordpress-cron/#post-16380192)
 * Hi [@ingohaeck](https://wordpress.org/support/users/ingohaeck/),
   I’ve added a
   check for `REQUEST_METHOD` in the code, so you will not see the warning for that
   if it is not available. That being said, do note that it is important for the
   plugin to run. So, instead of ignoring it you should definitely check in your
   server config to find out why it is missing as it is used by the plugin.
 * Secondly, I did not add any checks for `HTTP_HOST`, and I think it is a good 
   thing that the system throws warning when it is not available as it is critically
   used inside the plugin. And if it is missing, then the plugin won’t be able to
   do a few things. So, it is a good thing that the warning is being thrown so that
   the user can either talk to the host or check the server config about why these
   values are missing.
 * Please [try this new build of the plugin](https://verti-artifacts.s3.amazonaws.com/WP-Cloudflare-Super-Page-Cache-development-04d7ce9f/wp-cloudflare-page-cache.zip),
   and with this new build, hopefully you will not see the warning messages for `
   REQUEST_METHOD`, but you will still get the message for `HTTP_HOST` as stated
   above.
 * Let me know after trying this new build.
 *  Thread Starter [ingohaeck](https://wordpress.org/support/users/ingohaeck/)
 * (@ingohaeck)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/error-while-executing-wordpress-cron/#post-16380331)
 * Hi [Saumya Majumder](https://wordpress.org/support/users/isaumya/)
 * Thx. The error concerning REQUEST_METHOD is not shown anymore, but the one HTTP_HOST
   still exists, as expected.
 * I switched the PHP version for the cronjob to PHP 7.4. With this version I got
   no errors.
 *  Plugin Contributor [iSaumya](https://wordpress.org/support/users/isaumya/)
 * (@isaumya)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/error-while-executing-wordpress-cron/#post-16380356)
 * Hi [@ingohaeck](https://wordpress.org/support/users/ingohaeck/),
   As I said you
   should check why `HTTP_HOST` is missing as it is actively used by the plugin.
 *  Thread Starter [ingohaeck](https://wordpress.org/support/users/ingohaeck/)
 * (@ingohaeck)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/error-while-executing-wordpress-cron/#post-16380395)
 * HI [Saumya Majumder](https://wordpress.org/support/users/isaumya/),
 * Thank you. I contacted the Plesk support and asked them to investigate this. 
   Perhaps it is a Plesk bug.
 *  Thread Starter [ingohaeck](https://wordpress.org/support/users/ingohaeck/)
 * (@ingohaeck)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/error-while-executing-wordpress-cron/#post-16385985)
 * Hi,
 * A supporter of Plesk changed the code to:
 *     ```wp-block-code
       if( ( !defined( 'WP_CLI' ) || (defined('WP_CLI') && WP_CLI === false) ) && isset($_SERVER['REQUEST_METHOD']) && $_SERVER["REQUEST_METHOD"] == 'GET' && !is_admin() && !$this->is_login_page() && $this->get_single_config('cf_fallback_cache', 0) > 0 && $this->objects['cache_controller']->is_cache_enabled() ) {
       ```
   
 * I am not sure, wether the code gets the variables in a manner, that the plugin
   can work with this. Please can you investigate it.
   Thank you
 *  Plugin Contributor [iSaumya](https://wordpress.org/support/users/isaumya/)
 * (@isaumya)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/error-while-executing-wordpress-cron/#post-16386076)
 * Hi [@ingohaeck](https://wordpress.org/support/users/ingohaeck/),
   I don’t see 
   any changes in the code it’s the same as the code I’ve shipped to you in the 
   latest build of the plugin. Just ask then about why `$_SERVER['HTTP_HOST']` and`
   $_SERVER['REQUEST_METHOD']` is not returning any values as they should.
 *  [supporter9000](https://wordpress.org/support/users/supporter9000/)
 * (@supporter9000)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/error-while-executing-wordpress-cron/#post-16386962)
 * > I don’t see any changes in the code it’s the same as the code I’ve shipped 
   > to you in the latest build of the plugin.
 * Where have you been looking [@isaumya](https://wordpress.org/support/users/isaumya/)?
   The last comment by Ingo refers to line 567 in wp-cloudflare-super-page-cache.
   php. The plugin as it ships at the moment (downloaded via [https://downloads.wordpress.org/plugin/wp-cloudflare-page-cache.zip](https://downloads.wordpress.org/plugin/wp-cloudflare-page-cache.zip))
   does a string case compare there, this seems to fail with php 8+:
 *     ```wp-block-code
       strcasecmp($_SERVER['REQUEST_METHOD'], 'GET') == 0 && !is_admin()
       ```
   
 * While the code that Ingo posted does an isset, and then compares the strings 
   with ==, this seems to work:
 *     ```wp-block-code
       isset($_SERVER['REQUEST_METHOD']) && $_SERVER["REQUEST_METHOD"] == 'GET' && !is_admin()
       ```
   
 * Please take a look at [https://wordpress.org/support/topic/php-warning-undefined-array-key-request_method/](https://wordpress.org/support/topic/php-warning-undefined-array-key-request_method/)
   as well as Ingo initially suggested.
 * Cheers.
 *  [supporter9000](https://wordpress.org/support/users/supporter9000/)
 * (@supporter9000)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/error-while-executing-wordpress-cron/#post-16387022)
 * Oh, just for the record, adding only that isset before the original code seems
   to work as well:
 *     ```wp-block-code
       && isset($_SERVER['REQUEST_METHOD']) && strcasecmp($_SERVER['REQUEST_METHOD'], 'GET') == 0 && !is_admin()
       ```
   
 *  Plugin Contributor [iSaumya](https://wordpress.org/support/users/isaumya/)
 * (@isaumya)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/error-while-executing-wordpress-cron/#post-16388423)
 * Hi [@supporter9000](https://wordpress.org/support/users/supporter9000/),
   Have
   you checked this comment: [https://wordpress.org/support/topic/error-while-executing-wordpress-cron/#post-16380192](https://wordpress.org/support/topic/error-while-executing-wordpress-cron/#post-16380192)
   where I have linked to the new dev build. Try that out.

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘Error while executing wordpress cron’ is closed to new replies.

 * ![](https://ps.w.org/wp-cloudflare-page-cache/assets/icon-256x256.gif?rev=3234997)
 * [Super Page Cache – Cloudflare Cache, Page Speed & Core Web Vitals](https://wordpress.org/plugins/wp-cloudflare-page-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-cloudflare-page-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-cloudflare-page-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-cloudflare-page-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-cloudflare-page-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-cloudflare-page-cache/reviews/)

## Tags

 * [cronjob](https://wordpress.org/support/topic-tag/cronjob/)

 * 12 replies
 * 3 participants
 * Last reply from: [iSaumya](https://wordpress.org/support/users/isaumya/)
 * Last activity: [3 years, 4 months ago](https://wordpress.org/support/topic/error-while-executing-wordpress-cron/#post-16388423)
 * Status: resolved