-
Notifications
You must be signed in to change notification settings - Fork 974
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
Remove url guesswork #1362
Remove url guesswork #1362
Conversation
To summarize, because we'd be maybe changing the URL until config has been eval'd, There's a lot of code that runs in An alternative: what if we added some fancy regex to sniff out and execute those conditional includes?
This will always be the most explicit, and best, way to define your URL context. |
I know, I actually didn't expect it to work. And when it did, I really didn't expect the existing tests to all pass; you can imagine my surprise when they did. The url isn't really required for single-site installs. It is for multisite installs, because they will redirect the request if the url doesn't match (which is why the initial example fails silently), but single-site installs are a bit more flexible.
We could certainly try for some common exceptions, like
If it weren't for the hook, I think we'd be safe. I checked the core, core config, and db commands and as far as I can tell none of them use the url except The gist of what I'm trying to resolve here is two-fold. First, it's too easy to forget to explicitly set the URL, and the current guesswork is good enough to make the anomalies a head-scratcher. Second, having a yaml config or passing the url flag seems unnecessary, because the data is available -- if not in the config, then in the DB. If we can suss out the url without requiring it from the user, that makes wp-cli that much more simple to use. Here are a couple other ideas:
I'm open to other ideas and happy to work on the solution if we come up with a good option. |
This sounds similar to #854, which I'm really tempted to reopen. However, if your database credentials are in |
Why exactly is the If this change allows us to get rid of those ugly PHP-parsing regexes, without making things worse on multisite, I think it's worth pursuing. |
I think the next step then would be to add a battery of tests for it. I'll try to get that done this weekend and we'll go from there. |
When working with a multisite installation with variable wp-config files, e.g.
or even variable
DOMAIN_CURRENT_SITE
declarations, WP-CLI doesn't correctly parse the url (and, in fact, fails silently). To resolve this, WP_CLI requires using the--url
flag, or using a yaml config to explicitly set the url.This PR aims to resolve that by removing the guess, and setting the URL after the config is loaded. Perhaps there's rationale as to why the url must be set before the config is loaded; if so, can anyone explain why that is?
If there's interest in moving forward with this, I'll write tests for it.
Refs #263.