Skip to content
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

Conflict between field name and parameter name in wp site list prevents filtering by url #1939

Closed
priscillamc opened this issue Jul 24, 2015 · 14 comments

Comments

@priscillamc
Copy link

I ran into a problem trying to filter the wp site list by the url field. It looks like it's the same name as the --url parameter. http://wp-cli.org/commands/site/list/

Renaming the field to something other than 'url' could solve the problem.

Works: wp site list --blog_id=223

+---------+----------------------------------+---------------------+---------------------+
| blog_id | url                              | last_updated        | registered          |
+---------+----------------------------------+---------------------+---------------------+
| 223     | example.com/mysite1/             | 2015-07-24 14:24:32 | 2013-10-24 09:11:25 |
+---------+----------------------------------+---------------------+---------------------+

Bug: wp site list --url=example.com/mysite1/

Outputs all sites in the network because it's pretending that the request came from the given URL, not matching the url field.

+---------+----------------------------------+---------------------+---------------------+
| blog_id | url                              | last_updated        | registered          |
+---------+----------------------------------+---------------------+---------------------+
| 223     | example.com/mysite1/             | 2015-07-24 14:24:32 | 2013-10-24 09:11:25 |
+---------+----------------------------------+---------------------+---------------------+
| 224     | example.com/mysite2/             | 2015-07-24 14:24:32 | 2013-10-24 09:11:25 |
+---------+----------------------------------+---------------------+---------------------+
| 225     | example.com/mysite3/             | 2015-07-24 14:24:32 | 2013-10-24 09:11:25 |
+---------+----------------------------------+---------------------+---------------------+
@szepeviktor
Copy link
Contributor

It is a valid bug.
It looks like it'll be a breaking change but because the current usage is impossible it won't be really.

Also for --path.

@scribu
Copy link
Member

scribu commented Jul 24, 2015

One possible solution is to consider --url global if it comes before any positional argument. i.e.:

  • wp --url=somesite site list works as it does now
  • wp --url=somesite site list --url=differentsite works correctly
  • wp comment generate --url=somesite gives "unknown parameter for comment generate command: --url"

@szepeviktor
Copy link
Contributor

Escuse me. After looking at the code:
There is no url field in the database. It is an output-only field made up of domain and path.
So you may only filter by those fields.

I am sending a PR to clear up all these.

@scribu
Copy link
Member

scribu commented Jul 24, 2015

There is no url field in the database. It is an output-only field made up of domain and path.

That's just an implementation detail. No reason the command couldn't work around it.

@szepeviktor
Copy link
Contributor

I suggest to have site_url and site_path to avoid mixing globals and command specific options.

@priscillamc
Copy link
Author

Having two different --url parameters seems confusing. I'd prefer using a different name.

@szepeviktor
Copy link
Contributor

Please take a look at #1940.

@danielbachhuber
Copy link
Member

One possible solution is to consider --url global if it comes before any positional argument.

This is my preference, but it will be a breaking change.

Related #1222

I suggest to have site_url and site_path to avoid mixing globals and command specific options.

I'm not keen the rename the fields, as it doesn't solve the larger problem.

@szepeviktor
Copy link
Contributor

I'm not keen the rename the fields, as it doesn't solve the larger problem.

Then maybe rename the global --url?
--request-url ??

@danielbachhuber
Copy link
Member

Then maybe rename the global --url?

Per my initial comment, this is the route we'll eventually take:

One possible solution is to consider --url global if it comes before any positional argument.

However, it would be a relatively substantial breaking change, so won't happen until v1.0.0 (if / when that comes).

@priscillamc
Copy link
Author

Any recommendations on a way to look up a certain site's id? wp db query?

@szepeviktor
Copy link
Contributor

wp site list --url=example.com/mysite1/ --fields=blog_id,url | grep "^224\b" | cut -f 2
224 is the site you're looking for.

@muddylogic
Copy link

Would it be possible, rather than requiring positional arguments to change the filter parameters to be prefixed by filter? Something like --filter-url and --filter-path? Adding this, rather than changing existing parameters would allow for deprecation of the other filters while adding immediate functionality.

@danielbachhuber
Copy link
Member

While we still have this issue with global vs. local arguments, this particular issue is actually a documentation bug, as wp site list doesn't support filtering based on the 'url' argument in the first place. The 'url' value on a site object isn't stored in the database, but rather generated on the fly. I'm going to update the documentation as such.

You can filter wp site list with --domain=<domain> and --path=<path> because those columns exist in the database.

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

No branches or pull requests

5 participants