Make WordPress Core

Opened 8 months ago

Closed 2 days ago

#59514 closed enhancement (fixed)

Add more context to split_the_query filter

Reported by: spacedmonkey's profile spacedmonkey Owned by: spacedmonkey's profile spacedmonkey
Milestone: 6.6 Priority: normal
Severity: normal Version: 3.4
Component: Query Keywords: has-patch commit
Focuses: performance Cc:

Description

Current the split_the_query filter has the current WP_Query instance as context. However to calculate the value you need the value variables.

  • $old_request
  • $limits
  • $fields
  • $q ( query arguments ).

It is worth noting that $this->request can be received by WP_Query instance and $wpdb->posts can be received from global $wpdb.

With this extra context, will be make the filter much more useful.

Attachments (3)

59514.diff (1.5 KB) - added by rcorrales 3 months ago.
59514.patch (1.5 KB) - added by shailu25 4 days ago.
Refreshed Patch
59514.2.patch (1.5 KB) - added by shailu25 4 days ago.
Refreshed Patch.

Download all attachments as: .zip

Change History (18)

This ticket was mentioned in PR #5363 on WordPress/wordpress-develop by @spacedmonkey.


8 months ago
#1

  • Keywords has-patch added

#2 @spacedmonkey
8 months ago

Ping @tillkruess for review.

#3 @tillkruess
8 months ago

Huge +1. No downsides.

This ticket was mentioned in Slack in #core-performance by mukeshpanchal27. View the logs.


4 months ago

This ticket was mentioned in Slack in #core by audrasjb. View the logs.


3 months ago

#6 @audrasjb
3 months ago

Hi there, so you think this one can be committed in time for beta 1 tomorrow?

Also please note that the @since mention needs to be updated in the docblock.

@rcorrales
3 months ago

#7 @rcorrales
3 months ago

Hi, attached is a patch with similar changes as the current PR, but adding the @since to the docblock and removing the $q parameter as it is available through $query->query_vars.

#8 @audrasjb
3 months ago

  • Milestone changed from 6.5 to 6.6

As per today's pre-release party check, let's move this one to milestone 6.6 as we're very close to release 6.5 beta 1.

This ticket was mentioned in Slack in #core-performance by mukeshpanchal27. View the logs.


2 months ago

This ticket was mentioned in Slack in #core-performance by mukeshpanchal27. View the logs.


4 weeks ago

#11 @oglekler
4 days ago

@spacedmonkey, can you proceed with the patch?

@shailu25
4 days ago

Refreshed Patch

@shailu25
4 days ago

Refreshed Patch.

#12 @shailu25
4 days ago

I have refreshed the patch & also changed in docs. Added @since 6.6.0 instead of @since 6.5.0.

Patch: https://core.trac.wordpress.org/attachment/ticket/59514/59514.2.patch

#13 @spacedmonkey
2 days ago

  • Owner set to spacedmonkey
  • Status changed from new to assigned

#14 @spacedmonkey
2 days ago

  • Keywords commit added

#15 @spacedmonkey
2 days ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 58180:

Query: Add more context to the split_the_query filter.

Add more context to the split_the_query filter by adding two new parameters: '$old_request' and '$clauses'. This enriches the filter with additional information about the SQL query before the query is run, enabling developers to have more context to help decide if a query should be split.

Props spacedmonkey, shailu25, rcorrales, tillkruess.
Fixes #59514.

Note: See TracTickets for help on using tickets.