• Resolved speed4trade

    (@speed4trade)


    Hello,

    we access our WordPress instance also via cli (wp cli …). For example, to update all plugins.
    In this case, however, the contact form 7 plugin triggers a PHP warning:
    PHP Warning: Undefined array key “HTTP_HOST” in /var/www/www.xxx.com/wp-content/plugins/contact-form-7-honeypot/freemius/includes/class-freemius.php on line 3949

    Looking at the code shows this block:
    $this->_storage->connectivity_test = array(
    ‘is_connected’ => $is_connected,
    ‘host’ => $_SERVER[‘HTTP_HOST’],
    ‘server_ip’ => WP_FS__REMOTE_ADDR,
    ‘is_active’ => $is_active,
    ‘timestamp’ => WP_FS__SCRIPT_START_TIME,
    // Last version with connectivity attempt.
    ‘version’ => $version,
    );

    Is it possible to handle the case, when HTTP_HOST is empty (because its accessed via “wp cli”)?
    A possible solution might be:
    ‘host’ => isset($_SERVER[‘HTTP_HOST’]) ? $_SERVER[‘HTTP_HOST’] : ‘localhost’,

    Thanks! Thomas

    (moved from https://ww.wp.xz.cn/support/topic/undefined-array-key-http_host-in-class-freemius-php-on-line-3949/#post-18775703)

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support fahadwaheed

    (@fahadwaheed)

    Hi @speed4trade,

    I hope you’re doing well!

    Thank you for reaching out to the CF7 Apps Support Team. I’m happy to assist you.

    I’ve forwarded your query to our Technical Team for review. They are investigating the issue and will get back to you shortly with an update.

    Best regards,
    WP Experts Support Team

    Plugin Support fahadwaheed

    (@fahadwaheed)

    Hi @speed4trade,

    We apologize for the delayed response. We have replicated this on our staging environment and have not found any warnings so far. Could you please let us know your WordPress and PHP versions, and also confirm if this warning still appears on your site?

    Thread Starter speed4trade

    (@speed4trade)

    Hello @fahadwaheed

    following lines show the requested information:
    PHP version is 8.3.6
    WordPress 6.9
    OS: Ubuntu 24.04 LTS

    We have a scheduled update script which uses the official cli tool “wp” to update plugins.
    e.g.
    sudo -u www-data /usr/local/bin/wp plugin update $plugin
    sudo -u www-data /usr/local/bin/wp core update
    sudo -u www-data /usr/local/bin/wp language plugin update –al

    One of these commands triggers sometimes the PHP warning:
    PHP Warning: Undefined array key "HTTP_HOST" in /var/www/www.speed4trade.com/wp-content/plugins/contact-form-7-honeypot/freemius/includes/class-freemius.php on line 3949
    Warning: Undefined array key "HTTP_HOST" in /var/www/www.speed4trade.com/wp-content/plugins/contact-form-7-honeypot/freemius/includes/class-freemius.php on line 3949


    The warning is triggered maybe 1 or 2 times per week. So it is not reproducable every time. Maybe the warning is triggered, when some upates occur.
    The reason of the warning itself seems clear, the HTTP-header HTTP_HOST is not set and the mentioned $_SERVER[‘HTTP_HOST’]  is accessing a non-existing field. Thus an “if isset” would make it more robust and prevent the warning in any case.
    The last warning was triggered on monday the 12th, 4pm MEZ

    Plugin Support fahadwaheed

    (@fahadwaheed)

    Hi @speed4trade

    Please create a ticket on our technical support channel so that we can connect you directly with our Technical team.

    Looking forward to getting your issue resolved.

    Thread Starter speed4trade

    (@speed4trade)

    Thanks, I created a ticket as suggested.

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

You must be logged in to reply to this topic.