Make WordPress Core

Changeset 58180


Ignore:
Timestamp:
05/20/2024 09:19:21 PM (2 years ago)
Author:
spacedmonkey
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-query.php

    r58122 r58180  
    33143314                         *
    33153315                         * @since 3.4.0
     3316                         * @since 6.6.0 Added the `$old_request` and `$clauses` parameters.
    33163317                         *
    33173318                         * @param bool     $split_the_query Whether or not to split the query.
    33183319                         * @param WP_Query $query           The WP_Query instance.
     3320                         * @param string   $old_request     The complete SQL query before filtering.
     3321                         * @param string[] $clauses {
     3322                         *     Associative array of the clauses for the query.
     3323                         *
     3324                         *     @type string $where    The WHERE clause of the query.
     3325                         *     @type string $groupby  The GROUP BY clause of the query.
     3326                         *     @type string $join     The JOIN clause of the query.
     3327                         *     @type string $orderby  The ORDER BY clause of the query.
     3328                         *     @type string $distinct The DISTINCT clause of the query.
     3329                         *     @type string $fields   The SELECT clause of the query.
     3330                         *     @type string $limits   The LIMIT clause of the query.
     3331                         * }
    33193332                         */
    3320                         $split_the_query = apply_filters( 'split_the_query', $split_the_query, $this );
     3333                        $split_the_query = apply_filters( 'split_the_query', $split_the_query, $this, $old_request, compact( $pieces ) );
    33213334
    33223335                        if ( $split_the_query ) {
Note: See TracChangeset for help on using the changeset viewer.