#32504 closed enhancement (fixed)
WP_Network_Query class
Reported by: | jeremyfelt | Owned by: | jeremyfelt |
---|---|---|---|
Milestone: | 4.6 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Networks and Sites | Keywords: | has-patch has-unit-tests |
Focuses: | multisite | Cc: |
Description
Work on WP_Network
is being done in #31985 and will soon split several methods into a WP_Network_Query
class. While these two tickets exist very much in tandem, it makes sense to track logistical progress on each in separate tickets.
The WP_Network_Query
class should be responsible for all of the database queries required to maintain and find WP_Network
objects.
Attachments (8)
Change History (48)
This ticket was mentioned in Slack in #core-multisite by jeremyfelt. View the logs.
10 years ago
#3
in reply to:
↑ 2
@
9 years ago
- Milestone changed from 4.3 to Future Release
Replying to spacedmonkey:
- Will it have meta_query functionality, like other query classes? I think there is value in being able to query networks (sites) by sitemeta.
Great question. I haven't given this area too much thought yet, but I think there is room for some meta query functionality.
- How much will these queries be cached? I think that network queries should return quickly, as I worry that if these queries are slow, it could be a serious bottle neck in the multisite bootstrapping process.
IMO, all of the queries should be cached, though some things will be super quick or unnecessary for single (or few) network installs.
I'm going to push this back to future release with the hope that progress will continue over the next few months for early inclusion in the 4.4 cycle.
This ticket was mentioned in Slack in #core by wonderboymusic. View the logs.
9 years ago
This ticket was mentioned in Slack in #core-multisite by flixos90. View the logs.
9 years ago
#6
@
9 years ago
- Keywords has-patch added; needs-patch removed
32504.diff is an initial take on WP_Network_Query
. I took an approach similar to the other recent query classes where only the ID is queried. These IDs are then (if necessary) transformed into objects through a new get_network()
function. I also added related method to prime the network cache. Network meta (also known as network options or site options, stored in the sitemeta table) is also supported.
This is just a first patch that definitely needs to be enhanced and extended. Specifically I think it would be great to directly support a super_admin
parameter which the class will automatically handle and transform it into a meta query for it. There are other use-cases as well, specifically I'm taking the use-cases from the WP Multi Network plugin into account.
The patch also introduces a new function get_networks()
which makes use of WP_Network_Query
, so this is a good way to test it.
This ticket was mentioned in Slack in #core-multisite by jeremyfelt. View the logs.
9 years ago
This ticket was mentioned in Slack in #core-multisite by jeremyfelt. View the logs.
9 years ago
#10
@
9 years ago
- Keywords has-unit-tests added; needs-unit-tests removed
In 32504.2.diff I added unit tests for the class. Maybe we can still get this rolling to aim for a 4.6 merge, so I would appreciate some feedback.
I think for the initial merge we should keep the class simple as it currently is. In the future we might consider adding features like querying networks by sites in the network, by super admins, maybe even by a specific user in the network - but let's not get into this just yet.
This ticket was mentioned in Slack in #core-multisite by flixos90. View the logs.
9 years ago
This ticket was mentioned in Slack in #core-multisite by jeremyfelt. View the logs.
9 years ago
This ticket was mentioned in Slack in #core-multisite by jeremyfelt. View the logs.
9 years ago
#17
@
9 years ago
Leaving a reminder to remove the $object
parameter from get_network()
, similar to get_site()
.
#18
@
9 years ago
32504.3.diff removes the $output
parameter from get_network()
. It also uses get_network()
in wp_get_network()
which we will deprecate as discussed earlier. Since ms-deprecated.php
is however not loaded when bootstrapping the multisite environment, we probably need to leave this function in ms-load.php
. I didn’t add a deprecated notice just yet because of that.
Note that wp_get_network()
is expected to return false if no network is found, therefore the type juggling in there.
#19
follow-up:
↓ 20
@
9 years ago
Where does the clean_network_cache function need to be applied? When you update network options? That would effect meta queries. There is no delete / add / update network. However there is populate_network.
Also trying to find some uses in core for this class.
network_domain_check
get_main_network_id
get_admin_users_for_domain
#20
in reply to:
↑ 19
@
8 years ago
Replying to spacedmonkey:
Where does the clean_network_cache function need to be applied? When you update network options? That would effect meta queries.
I'm not sure if it can be used anywhere in Core since Multinetwork is mostly plugin-territory atm. Using the function when network options (sitemeta) is updated could indeed make sense, however as far as I can see other meta areas of Core don't clean the cache of their object either when updating - correct me if I'm wrong here.
There is no delete / add / update network. However there is populate_network.
It might make sense to use it there too. However I have never looked at that function in detail.
I think for now, we should work on the class itself and its surrounding functionality to hopefully get it into 4.6 - using it in Core could be done later (it would only be in very few areas anyway). What do you think @jeremyfelt? Also additional eyes from @johnjamesjacoby would be helpful since this is likely to be adopted in WP Multi Network.
Sorry for all the pings :)
#21
@
8 years ago
The unit tests got lost in 32504.3.diff. They have now been added back in with 32504.4.diff.
#22
@
8 years ago
- Keywords needs-testing removed
Due to the unclear nature of network options (which theoretically allow to do a meta query, but they aren't currently dealt with as meta) we'll aim for a 4.6 merge of the class without any meta query (which in our terminology is rather an option query) functionality. We'll deal with this in a later ticket as we have to figure out which way we wanna go with network options. Related: #37181
#23
@
8 years ago
32504.6.diff includes the fix for the found_posts query from WP_Site_Query
that applies here as well.
#24
@
8 years ago
In 32504.7.diff, I made a couple doc tweaks and removed the to_array()
method from WP_Network
. I don't believe we need this because we don't have the same back-compat concerns here (or at least not yet).
This ticket was mentioned in Slack in #core by ocean90. View the logs.
8 years ago
#30
follow-up:
↓ 31
@
8 years ago
heads up, it will conflict with WP Multi Network v1.7.0:
Fatal error: Cannot redeclare get_networks() (previously declared in \wp-includes\ms-blogs.php:1084) in \wp-content\plugins\wp-multi-network\includes\functions-wp-ms-networks.php on line 51
#31
in reply to:
↑ 30
@
8 years ago
Replying to geminorum:
heads up, it will conflict with WP Multi Network v1.7.0:
Fatal error: Cannot redeclare get_networks() (previously declared in \wp-includes\ms-blogs.php:1084) in \wp-content\plugins\wp-multi-network\includes\functions-wp-ms-networks.php on line 51
Hi @geminorum, thanks for the heads up. This should be addressed in WP Multi Network soon - https://github.com/stuttter/wp-multi-network/pull/75
#32
@
8 years ago
32504-dontcache-max_num_pages.diff is an updated patch related to similar change in wp_site_query.
#33
@
8 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
Re-opening to address concerns from fixing the found rows issue in comment queries. See https://core.trac.wordpress.org/ticket/37184#comment:7
I had two questions about this class.