Undefined index: HTTP_HOST; wp-config.php wrong for wp-cli

Bug #1730522 reported by Andrew on 2017-11-06
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
wordpress (Ubuntu)
Undecided
Unassigned

Bug Description

$ sudo wp option update home "http://localhost" --allow-root
PHP Notice: Undefined index: HTTP_HOST in phar:///data/local/bin/wp/php/WP_CLI/Runner.php(1070) : eval()'d code on line 10
Neither <b>/etc/wordpress/config-.php</b> nor <b>/etc/wordpress/config-.php</b> could be found. <br/> Ensure one of them exists, is readable by the webserver and contains the right password/username.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The following code should be added to /usr/share/wordpress/wp-config.php so as to facilitate wp-cli usage, as delineated here: https://make.wordpress.org/cli/handbook/common-issues/#php-notice-undefined-index-on-_server-superglobal

if ( defined( 'WP_CLI' ) && WP_CLI && ! isset( if ( defined( 'WP_CLI' ) && WP_CLI && ! isset( $_SERVER['HTTP_HOST'] ) ) {
    $_SERVER['HTTP_HOST'] = 'wp-cli.org';
}

root@yellow:/usr/share/doc/wordpress# lsb_release -rd
Description: Ubuntu 16.04.3 LTS
Release: 16.04
root@yellow:/usr/share/doc/wordpress# apt-cache policy wordpress
wordpress:
  Installed: 4.4.2+dfsg-1ubuntu1
  Candidate: 4.4.2+dfsg-1ubuntu1
  Version table:
 *** 4.4.2+dfsg-1ubuntu1 500
        500 http://us.archive.ubuntu.com/ubuntu xenial/universe amd64 Packages
        500 http://us.archive.ubuntu.com/ubuntu xenial/universe i386 Packages
        100 /var/lib/dpkg/status

ProblemType: Bug
DistroRelease: Ubuntu 16.04
Package: wordpress 4.4.2+dfsg-1ubuntu1
ProcVersionSignature: Ubuntu 4.4.0-98.121-generic 4.4.90
Uname: Linux 4.4.0-98-generic x86_64
ApportVersion: 2.20.1-0ubuntu2.10
Architecture: amd64
CurrentDesktop: Unity
Date: Mon Nov 6 13:24:11 2017
InstallationDate: Installed on 2017-10-13 (24 days ago)
InstallationMedia: Ubuntu 16.04.1 LTS "Xenial Xerus" - Release amd64 (20160719)
PackageArchitecture: all
SourcePackage: wordpress
UpgradeStatus: No upgrade log present (probably fresh install)

Andrew (publicface) wrote :
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers