• Resolved p15h

    (@prestonwordsworth)


    PHP Warning:  Undefined array key "HTTP_HOST" in /home/www/htdocs/wp-content/plugins/wp-cloudflare-page-cache/libs/html_cache.class.php on line 79
    Warning: Undefined array key "HTTP_HOST" in /home/www/htdocs/wp-content/plugins/wp-cloudflare-page-cache/libs/html_cache.class.php on line 79

    Dear Majumder

    This issue seems to be prevalent across a host of plugins. From what I’ve read, the fix seems to be relatively straightforward: see here and here. Could we use a solution similar to what’s proposed in the second link if(!isset($_SERVER['HTTPS'])) return; ?

    FYI, our own use case for WP CLI is in a setup using Linux’s crontab in place of WP Cron to run cron jobs including those for this plugin.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Contributor iSaumya

    (@isaumya)

    Hi @prestonwordsworth,
    I totally understand why you opened this thread, but it is not that easy to implement here as HTTP_HOST is used in both the advanced-cache.php and html_cache system. Returning from there when does not exist will cause many issues as the plugin is highly dependent on those values.

    This is why we can’t just look elsewhere when it does not exist. The plugin uses it in many different ways in many different places.

    Thread Starter p15h

    (@prestonwordsworth)

    Got it! So in this case it seems best to just ignore the php warnings.

    Plugin Contributor iSaumya

    (@isaumya)

    Hi @prestonwordsworth,
    Yes just ignore the warnings…

    Is there any better way to handle $_SERVER['HTTP_HOST'] not beeing set, in html_cache.class.php?
    On servers running UNIX cron, a common crontab implementation is:
    * * * * * cd /sites/example.com/files/; /usr/local/bin/wp cron event run --due-now >/dev/null 2>&1
    So cron is fired via WP CLI. But the $_SERVER variable is not set up during WP CLI requests.
    Similarly, $_SERVER['REQUEST_URI'] will not be defined, on the same line in html_cache.class.php.
    So logs for all our sites are filled with these warnings at all times.
    It’s not a functional problem, but makes our logs tough to navigate.
    This will be the case for those running SpinupWP and other server panels.

    Just a thought: you are already checking for WP_CLI in the add_current_url_to_cache() method. Moving the WP_CLI check above the $current_url = "{$parts... line fixes the problem. Would that work?

    Thank you!

    Plugin Contributor iSaumya

    (@isaumya)

    Hi @hartl,
    Can you please try out this build of the plugin and let me know if this resolves your issue or not?

    Hi @isaumya,
    Apologies about the late reply. It looks like the link has expired.
    If you can update the link I will test it out.

    Plugin Contributor iSaumya

    (@isaumya)

    Hi @hartl,
    Please try this build. Let me know if it works.

    Hi @isaumya ,
    thanks for the updated link, however it gives me “access denied”. Can you have a look?

    Plugin Contributor iSaumya

    (@isaumya)

    Hi @hartl,
    Sorry for that! Try this link, I’ve checked it’s working.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘HTTP_HOST in local environment WP-CLI’ is closed to new replies.