Undefined array key “HTTP_HOST” in class-freemius.php on line 3949
-
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
You must be logged in to reply to this topic.