#45749 closed enhancement (fixed)
Add short circuits for multisite classes.
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 5.2 | Priority: | normal |
Severity: | normal | Version: | 4.6 |
Component: | Networks and Sites | Keywords: | has-patch has-dev-note |
Focuses: | multisite | Cc: |
Attachments (13)
Change History (45)
This ticket was mentioned in Slack in #core-multisite by spacedmonkey. View the logs.
6 years ago
This ticket was mentioned in Slack in #core-multisite by spacedmonkey. View the logs.
6 years ago
#6
@
6 years ago
- Milestone changed from Future Release to 5.2
- Owner changed from spacedmonkey to adamsilverstein
#7
@
6 years ago
Diff without whitespace changes: https://cl.ly/39d47b7b732f
#8
@
6 years ago
45749.3.diff add a test for sites_pre_query
#9
@
6 years ago
Note: tests are failing due to phpcs after this patch.
Fixing these issues would require changing queries so leaving as is for now.
https://travis-ci.org/adamsilverstein/wordpress-develop-fork/builds/506014981
#11
@
6 years ago
@desrosj feeling good about the patch as is and will commit today, I'm going to leave the phpcs errors in existing code untouched to avoid any possibility of breaking changes.
#13
@
6 years ago
@adamsilverstein This ticket is for both wp_site_query and wp_network_query filters. Is it possible to add the network query in the same patch or should this be a different ticket?
#14
@
6 years ago
@spacedmonkey - We can add it in the same patch - is this the code in https://core.trac.wordpress.org/attachment/ticket/45749/45749.diff ? I missed that separate code earlier, usually diffs are cumulative :)
#15
@
6 years ago
Note: I'm seeing test failures after this patch: https://cl.ly/75742cc9d73a https://travis-ci.org/adamsilverstein/wordpress-develop-fork/jobs/509641958
Tests_User_Query::test_sites_pre_query_filter_should_bypass_database_query - Error: Class 'WP_Site_Query' not found
at tests/phpunit/tests/user/query.php:1737
#16
@
6 years ago
Updated the patch, mixing two patches together and moving the test to the correct file.
@adamsilverstein .
https://core.trac.wordpress.org/attachment/ticket/45749/45749.5.diff
#17
@
6 years ago
In 45749.6.diff is a different patch, for network query. Both 45749.5.diff and 45749.6.diff should be committed as different commits.
#18
@
6 years ago
@spacedmonkey Thanks! Running tests on 45749.5.diff, code looks good.
Does this look good for the commit message?
Multisite: add a
sites_pre_query
filter to short circuit WP_Site_Query queries.
Add a new filtersites_pre_query
- which returns null by default. Return a non-null value to bypass WordPress's defaultget_sites
queries. Similar to theposts_pre_query
filter for WP_Query added in #36687. This filter lets you short circuit the WP_Site_Query query to return your own results.
Developers should note that filtering functions that require pagination information are encouraged to set thefound_sites
property of the WP_Site_Query object, passed to the filter by reference. If WP_Site_Query does not perform a database query, it will not have enough information to generate these values itself.
#20
@
6 years ago
45749.5.diff is 45749.5.diff plus autofixes from phpcbf (applied with composer run format
) to fix some style errors.
Seeing some test failures: https://travis-ci.org/adamsilverstein/wordpress-develop-fork/builds/509713899
#21
@
6 years ago
Reuploaded as 45749.7.diff.
Commmit message looks good to me.
#22
@
6 years ago
Great! thanks for the new 45749.7.diff - these are so similar I missed that they are different at first.
Since they are so closely related, we can probably commit them together and I will expand my commit message to cover networks_pre_query
.
I am still seeing test failures in Travis for .5 https://travis-ci.org/adamsilverstein/wordpress-develop-fork/builds/509713899 and .7 https://travis-ci.org/adamsilverstein/wordpress-develop-fork/builds/509934427
#23
@
6 years ago
45749.8.diff combines both patches and fixes a few things that broke tests, some are still failing. @spacedmonkey is working on a fix.
#24
@
6 years ago
45749.9.diff - trying to simplify this a bit:
- uses local vs class variables for $network_ids and $site_ids
- removes unrelated whitespace changes except those fixable by
phpcbf
viewing the diff with whitespace changes disabled the changes are now very small - https://cl.ly/e61374e40f16 (or view here and turn off whitespace changes under diff settings: https://github.com/WordPress/wordpress-develop/pull/49/files)
This ticket was mentioned in Slack in #core-multisite by spacedmonkey. View the logs.
6 years ago
5 years ago
#30
Committed in https://core.trac.wordpress.org/changeset/44983.
5 years ago
#31
Committed in https://core.trac.wordpress.org/changeset/44983.
5 years ago
#32
Committed in https://core.trac.wordpress.org/changeset/44983.
There are two way I have gone about this.
pre_get_sites
which would allow you to change the class property of site_ids.sites_pre_query
similar to other filters existing in core.