Make WordPress Core

Opened 7 years ago

Last modified 7 years ago

#41819 assigned enhancement

Support the paged argument in WP_Site_Query and WP_Network_Query

Reported by: birgire's profile birgire Owned by: spacedmonkey's profile spacedmonkey
Milestone: Future Release Priority: normal
Severity: normal Version: 4.6
Component: Query Keywords: has-patch has-unit-tests dev-feedback
Focuses: multisite Cc:

Description

The WP_Site_Query and WP_Network_Query both support the offset and number arguments.

It would be handy to be able to use the paged argument, to make the pagination easier.

Attachments (3)

41819.patch (11.1 KB) - added by birgire 7 years ago.
Support for 'paged' argument in WP_Site_Query and WP_Network_Query, with tests.
41819.2.patch (11.2 KB) - added by birgire 7 years ago.
Added the ticket number to the tests
41819.3.patch (10.5 KB) - added by birgire 7 years ago.
Here we focus on the calculated offset in the LIMIT clause.

Download all attachments as: .zip

Change History (8)

@birgire
7 years ago

Support for 'paged' argument in WP_Site_Query and WP_Network_Query, with tests.

#1 @birgire
7 years ago

  • Keywords has-patch has-unit-tests added

The patch adds the support for the paged argument in WP_Site_Query and WP_Network_Query.

It's similar to the approach in #38268, for the WP_Comment_Query, but I took a different approach in the tests. I tried to re-use the setup in:

  • Tests_Multisite_Site_Query::wpSetUpBeforeClass() and
  • Tests_Multisite_Network_Query::wpSetUpBeforeClass(),

using get_site_by() and get_network_by() to fix the test objects for the test queries. I will have to look better into that, if that's ok.

This patch also takes care of paged as 0, to avoid a negative start value in the LIMIT clause.

When it's 0 it's treated as the default value of 1.

Last edited 7 years ago by birgire (previous) (diff)

@birgire
7 years ago

Added the ticket number to the tests

@birgire
7 years ago

Here we focus on the calculated offset in the LIMIT clause.

This ticket was mentioned in Slack in #core-multisite by birgire. View the logs.


7 years ago

This ticket was mentioned in Slack in #core-multisite by desrosj. View the logs.


7 years ago

#4 @desrosj
7 years ago

  • Keywords dev-feedback added
  • Milestone changed from Awaiting Review to Future Release
  • Owner set to spacedmonkey
  • Status changed from new to assigned

Assigning to @spacedmonkey to shepherd.

After discussing this in today's ticket scrub, it was decided this is a good thing to add. It could help with Networks and Sites in the REST API, and adds parity to the other query classes in core. Will not make it into 4.9, but 5.0 is realistic.

#5 @stevenkword
7 years ago

There are a lot of tickets related to the LIMIT clauses. #42261 landed in feeds recently and @birgire has two other tickets open regarding similar issues. #41837, #41826

Note: See TracTickets for help on using tickets.