Skip to content

config.php loading too late in wp-config.php #894

Description

@banderon

I've run into an issue.

When running commands via WP-CLI, the $_SERVER['HTTP_HOST'] value isn't populated, so if you have code that uses that value (and expects it to be the current host), the value has to be manually set. I'd like to set this in content/config.php so that it can be included in the project repo. However, $_SERVER['HTTP_HOST'] is used to set constants in wp-config.php before loading config.php. This means that the only way to set the value before it's utilized is in a local-config.php file, which is outside the content folder and so can't be packaged up with a project.

Would it be too messy of a change to declare WP_CONTENT_DIR and load config.php directly after the Load Chassis extensions block? That is, load the project configs immediately after their local overrides. That would allow the project-level config to potentially allow the setting of a number of core values: ABSPATH, $_SERVER['HTTP_HOST'], and by extension all of the constants that are set from $_SERVER['HTTP_HOST'] (such as DOMAIN_CURRENT_SITE, WP_CONTENT_URL, WP_SITEURL, and WP_HOME—all of which might be used in a CLI command and would benefit from having the correct $_SERVER['HTTP_HOST'] value).

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions