bobbingwide / oik-batch

Batch interface to WordPress
https://www.oik-plugins.com/oik-plugins/oik-batch
GNU General Public License v2.0
0 stars 0 forks source link

Notice when $_SERVER['SERVER_PROTOCOL'] not set #25

Closed bobbingwide closed 6 years ago

bobbingwide commented 7 years ago

When running oik-wp.php, some installation's produce a notice from wp_get_server_protocol() when a loaded plugin calls a function that uses wp_get_server_protocol(). More often than not the process then dies.

Possible solutions

  1. Change WordPress core to not produce the notice
  2. Change oik-batch/oik-wp start up logic to set $_SERVER['SERVER_PROTOCOL']
  3. Change the plugin that leads to wp_get_server_protocol() being called, especially if it's attempting to call wp_redirect().
  4. Deactivate any offending plugin.

Note: Check if this is the same problem as detected with Notices from WP-CLI.

bobbingwide commented 7 years ago

Note: It was not the same problem as detected with notices from WP-CLI, which was:

Notice: Undefined index: SERVER_NAME in 
phar://path-to-file/wp-cli.phar/php/WP_CLI/Runner.php(982) : 
eval()'d code on line 18

This bug was easily tracked down. I switched to PHP 7.1, where Xdebug was enabled to automatically produce a stack trace on Notices. This showed that the problem was due to referencing $_SERVER['SERVER_NAME'] in wp-config.php.

bobbingwide commented 7 years ago
  1. I've added logic, in oik_batch_set_domain(), to set the value to null if it's not set. This'll let wp_get_server_protocol apply the default.

  2. I'll consider raising a WordPress TRAC.

  3. Automatically setting WP_CLI doesn't work since other plugins can break if WP_CLI is set but not actually loaded e.g. Akismet. For the actual plugin that's failing ( qtranslate-x) setting WP_ADMIN doesn't work either. WordPress core baulks since PHP_SELF does not contain wp-admin.