• Resolved harryyoud

    (@harryyoud)


    I run WP cron with a Linux crontab cron job:

    /usr/bin/php /var/www/redacted.site.com/public/wordpress/wp-cron.php

    Since this doesn’t run within the context of a HTTP request, some of the PHP $_SERVER variables will not be set, resulting in a warning in syslog

    PHP Warning: Undefined array key "HTTP_HOST" in /var/www/redacted.site.com/public/wordpress/wp-content/plugins/embed-soundcloud-block/index.php on line 17

    It 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)
  • Plugin Author btechnologies

    (@btechnologies)

    Hi @harryyoud

    Thank you very much for identifying the problem. We have fixed the issue and updated the new version. Please update to the latest version.

    Thank you!!

Viewing 1 replies (of 1 total)

The topic ‘PHP Warning when running outside of HTTP context’ is closed to new replies.