wp-cli: Cannot redeclare wp_get_server_protocol()

Hi, I just installed wp-cli to use with my wordpress 4.4.1 installation. When I run it in my home directory without arguments it outputs usage instructions but when I run it without arguments in my wordpress folder I get:

PHP Fatal error: Cannot redeclare wp_get_server_protocol() (previously declared in /var/www/html/stage2.rolandtichy.de/wp-includes/load.php:18) in /var/www/html/stage2.rolandtichy.de/wp-includes/load.php on line 23

I tried the latests release version of wp-cli and the current master branch both with the same result. I can reproduce the same error when I create a test.php and require(‘wp-includes/load.php’) twice so that’s what seems to happen when running wp-cli. Any idea what could cause this?

Output of wp --info:

PHP binary: /usr/bin/php
PHP version:    5.4.16
php.ini used:   /etc/php.ini
WP-CLI root dir:    phar://wp-cli.phar
WP-CLI global config:   
WP-CLI project config:  
WP-CLI version: 0.22.0

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 16 (6 by maintainers)

Most upvoted comments

I know it’s closed, but it might by a problem solution for those using wp-config-local.php when it’s available. Having same issue by getting:

Fatal error: Cannot redeclare wp_get_server_protocol() (previously declared in /siteroot/v1/wp-includes/load.php:16) in /siteroot/v1/wp-includes/load.php on line 21

I was able to overcome it by removing usual:

/** Use local config file if exists */ if ( file_exists( dirname( __FILE__ ) . '/wp-config-local.php' ) ) { include( dirname( __FILE__ ) . '/wp-config-local.php' ); }

from the wp-config.php file.

Might it make sense to add this check to wp-cli? Or is there a proper way to use wp-config-local.php so that wp-cli still works?

wp --skip-themes makes it work but I can find no reference to wp-includes/load.php in wp-content/themes/*.

Thanks Daniel. Would you believe it, I tracked it down to a dodgy plugin that does:

include(functions.php');

😖

Well…yes, you probably would.