PHP Warning when running outside of HTTP context
-
I run WP cron with a Linux crontab cron job:
/usr/bin/php /var/www/redacted.site.com/public/wordpress/wp-cron.phpSince this doesn’t run within the context of a HTTP request, some of the PHP
$_SERVERvariables will not be set, resulting in a warning in syslogPHP Warning: Undefined array key "HTTP_HOST" in /var/www/redacted.site.com/public/wordpress/wp-content/plugins/embed-soundcloud-block/index.php on line 17It looks as though this check is used for checking localhost to set version of the plugin in the dev/testing environment. Could this be adapted from:
16 │ // Constant
17 │ if ('localhost' === $_SERVER['HTTP_HOST']) {
18 │ $plugin_version = time();
19 │ } else {
20 │ $plugin_version = '1.0.5';
21 │
22 │ }
23 │ define('SCB_PLUGIN_VERSION', $plugin_version);To something like:
16 │ // Constant
17 │ if (isset($_SERVER['HTTP_HOST']) && 'localhost' === $_SERVER['HTTP_HOST']) {
18 │ $plugin_version = time();
19 │ } else {
20 │ $plugin_version = '1.0.5';
21 │
22 │ }
23 │ define('SCB_PLUGIN_VERSION', $plugin_version);
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘PHP Warning when running outside of HTTP context’ is closed to new replies.