Support » Plugin: WP Super Cache » WP Super Cache Crashes PHP Cron JOb

  • I have WP Super Cache installed on a site that runs a cron job every so often to keep an inventory of products in sync. This cron job access a specific file in the plugins directory to run this and I keep getting an error that crashes my cron job when I access that file….

    PHP Notice:  Undefined index: HTTP_HOST in /pathOnServer/web/content/wp-content/plugins/wp-super-cache/wp-cache-base.php on line 4
    PHP Notice:  Undefined index: REQUEST_METHOD in /pathOnServer/web/content/wp-content/plugins/wp-super-cache/wp-cache-phase1.php on line 50
    PHP Notice:  Undefined index: SERVER_PORT in /pathOnServer/web/content/wp-content/plugins/wp-super-cache/wp-cache-phase1.php on line 104

    This is happening because you don’t have access to the HTTP_HOST when you are running a PHP Cron job. All I need is for WP Super Cache to run on the site but I don’t want it to be active at all for one particular file or a specific plugin directory.

    Any thoughts or suggestions??

    Thanks much.

    https://wordpress.org/plugins/wp-super-cache/

Viewing 9 replies - 1 through 9 (of 9 total)
  • What you show us are not crashes but php notices. I see no crash.

    Yes it is only notices. However, the cron job cannot progress past this. When I have WP Super Cache activated the cron job cannot complete. It stops right after the notices above. If I deactivate WP Super Cache the cron completes as normal. The Cron encounters line 4 of wp-cache-base.php which is

    $WPSC_HTTP_HOST = htmlentities( $_SERVER[ 'HTTP_HOST' ] );

    and it cannot get the HTTP_HOST since this is strictly a PHP request and the file isn’t accessed via an HTTP request. So yes while only a notice is being printed above it is what is causing my cron job to crash. A similar post about this http://stackoverflow.com/questions/9128488/cron-job-server-issue however I can’t wrap the request in an isset or hardcode the value since it is a core WP Super Config file.

    Hi Guys, we funny enough, have a similar problem… showing “live prices” on our website that come from a cron job… yet the entire page is being cached (damn well too I might add!) 🙂 however what may be a solution for having prices that regularly update (think every 5 minutes) on our site, yet still be able to use your fine software?

    Any reply guys?

    I haven’t heard anything back on this yet. Anyone have any thoughts? I was reading online about adding a constant DONOTCACHEPAGE and setting it to true to disable caching for that page, but I haven’t found any documentation on that. I also saw where you can disable caching for plugins, but I’m not sure if that will have any effect.

    Any thoughts or ideas anyone?

    Bozz

    (@bozzmedia)

    I have the same issues, I think it’s a bug but I’m not sure the devs have ever responded to the issue.

    I have posted previously about this here:

    PHP Fatal Error on Delete Cache & Settings Pages

    Ed Gifford

    (@ecgifford)

    I was searching for a resolution to this and landed here.

    It looks like Automattic knows about the issue and has plans to fix it:
    https://github.com/Automattic/wp-super-cache/issues/7

    There just doesn’t seem to be an ETA on it.

    Looking at how this section of plugin works, this is tricky problem. The site’s domain name isn’t stored in the plugin’s configuration file (wp-cache-config.php) and the plugin doesn’t want to look in the options table (to avoid DB hits during cache resolution), so the plugin is trying to tease out the domain name from various constants and environment variables. This gets more complicated because this plugin works with multisite.

    To sidestep this, maybe the plugin could detect CLI mode (cron jobs, WP-CLI, etc) and bail on loading the plugin:
    http://stackoverflow.com/a/2421484

    tmuka

    (@tmuka)

    I noticed this output too, using wp-cli. A workaround for people managing their own server would be to modify the /etc/php/cli.ini to set error_reporting to hide notices. Of course, i’d rather not see the notice generated by the plugin if it can be avoided. Thanks!

    Really hoping for some progress on this issue in 2017. Fingers crossed 🙂

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘WP Super Cache Crashes PHP Cron JOb’ is closed to new replies.