New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cases where $_SERVER['HTTP_HOST'] is used inside wp-config.php #730

Closed
scribu opened this Issue Aug 27, 2013 · 1 comment

Comments

2 participants
@scribu
Member

scribu commented Aug 27, 2013

Defining certain constants to be domain-agnostic is a sufficiently common practice to warrant consideration.

For example, the config file in markjaquith/WordPress-Skeleton has the following line:

define( 'WP_CONTENT_URL', 'http://' . $_SERVER['HTTP_HOST'] . '/content' );

If you run wp without passing a --url parameter, you will get a warning:

Notice: Undefined index: HTTP_HOST in /Users/User/.composer/vendor/wp-cli/wp-cli/php/wp-cli.php(20) : eval()'d code on line 19

Several workarounds were discussed in #676 (comment).

We already try to guess the URL by doing some ugly wp-config.php parsing via regular expressions.

A more reliable way would be to do a database query:

  • need to account for the case where WP isn't installed yet; see #663
  • need to account for multisite
@scribu

This comment has been minimized.

Show comment
Hide comment
@scribu

scribu Aug 31, 2013

Member

A more reliable way would be to do a database query:

There's a logical problem with that: we want to do a query before loading the wp-config.php file, but the database credentials are inside the wp-config.php file.

Member

scribu commented Aug 31, 2013

A more reliable way would be to do a database query:

There's a logical problem with that: we want to do a query before loading the wp-config.php file, but the database credentials are inside the wp-config.php file.

jeremyfelt added a commit to washingtonstateuniversity/WSUWP-Platform that referenced this issue Oct 30, 2013

Set a default HTTP_HOST for use with wp-cli
Our sunrise.php (and ms-settings.php if that's not around) require `HTTP_HOST` to be set in order to determine what domain and path are being requested.

If a wp-cli command is run without `--url` specified, `$_SERVER['HTTP_HOST']` is not available. This causes things to get confused on our end. Luckily, we can assume a default at the moment, wp.wsu.edu, and just specify it if the `WP_CLI_PHP_USED` server variable has been set.

See wp-cli/wp-cli#730 for possible future changes.

@danielbachhuber danielbachhuber added this to the 0.25.0 milestone Aug 23, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment