[wp-trac] [WordPress Trac] #35791: WP_Site_Query class
WordPress Trac
noreply at wordpress.org
Thu Jun 2 01:30:06 UTC 2016
#35791: WP_Site_Query class
-------------------------------------------------+-------------------------
Reporter: spacedmonkey | Owner: jeremyfelt
Type: task (blessed) | Status: reviewing
Priority: normal | Milestone: 4.6
Component: Networks and Sites | Version: 4.4
Severity: normal | Resolution:
Keywords: has-patch needs-testing has-unit- | Focuses: multisite
tests needs-dev-note |
-------------------------------------------------+-------------------------
Comment (by jeremyfelt):
Replying to [comment:57 dd32]:
> Just wanted to quickly weigh in on the usage of `ARRAY_A` here.. is it
really needed? and when would you ever want to do `ARRAY_N`?
> It looks like it's being used for BC, but, it feels like that if the
calling function is needing BC-data, it should be the one to massage the
new API's return format into something it understands. (ie. in r37617, it
should just be `$results[] = (array) get_site( $_site );`)
I think the biggest reason right now is alignment with `get_post()`,
`get_comment()`, and `get_term()`. I wouldn't be opposed to removing that
argument and providing a proper `WP_Site` object.
Because `ARRAY_A` is available, it's used to help `wp_get_sites()`
maintain back-compat.
> A potentially better option would even to just implement `ArrayAccess`
for `WP_Site` instead (Although that'll fail any `is_array()` checks that
people have added for some reason) but has the potential to reduce issues
and give a consistent object for the future.. unlike this, where legacy
code will still be passing arrays around, when it could just be using a
`WP_Site` object, reducing the amount of changes needed to "upgrade".
Good point, this could be a good way of encouraging those with legacy code
to switch to `get_sites()`.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/35791#comment:59>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list