Undefined array key “SERVER_NAME” when running under external Cron
-
Hi there,
We run WordPress’s Cron function via an external scheduler as documented here. However, since upgrading to PHP 8.0 the cron job output now has the following warning in it;
PHP Warning: Undefined array key "SERVER_NAME" in /home/sites/REMOVED/public_html/wp-content/mu-plugins/PluginOrganizerMU.class.php on line 20Looking at the code on line 20 in the version of the plugin we’re currently using (10.1.7), the line is;
$this->httpHostName = $_SERVER['SERVER_NAME'];As we’re invoking the cron script directly via the php CLI command, presumably the
$_SERVERarray doesn’t have aSERVER_NAMEkey like it does when PHP is invoked via a web server.For now, i’ve manually prefixed
$_SERVER['SERVER_NAME']with an@to suppress the warning, but this will be wiped out on any future upgrades.
The topic ‘Undefined array key “SERVER_NAME” when running under external Cron’ is closed to new replies.