Make WordPress Core

Changeset 53175


Ignore:
Timestamp:
04/14/2022 12:02:31 AM (2 years ago)
Author:
SergeyBiryukov
Message:

Query: Restore late compact() call for SQL clauses in wp-includes/class-wp-*-query.php.

This addresses a backward compatibility break where posts_groupby and other filters were applied, but their results were subsequently discarded and earlier values were used instead.

Follow-up to [52974].

Props nextend_ramona.
See #54728, #meta6273.

Location:
trunk/src/wp-includes
Files:
5 edited

Legend:

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

    r53169 r53175  
    918918        $where = implode( ' AND ', $this->sql_clauses['where'] );
    919919
    920         $clauses = compact( 'fields', 'join', 'where', 'orderby', 'limits', 'groupby' );
     920        $clauses = array( 'fields', 'join', 'where', 'orderby', 'limits', 'groupby' );
    921921
    922922        /**
     
    928928         * @param WP_Comment_Query $query   Current instance of WP_Comment_Query (passed by reference).
    929929         */
    930         $clauses = apply_filters_ref_array( 'comments_clauses', array( $clauses, &$this ) );
     930        $clauses = apply_filters_ref_array( 'comments_clauses', array( compact( $clauses ), &$this ) );
    931931
    932932        $fields  = isset( $clauses['fields'] ) ? $clauses['fields'] : '';
  • trunk/src/wp-includes/class-wp-network-query.php

    r53098 r53175  
    439439        $groupby = '';
    440440
    441         $clauses = compact( 'fields', 'join', 'where', 'orderby', 'limits', 'groupby' );
     441        $clauses = array( 'fields', 'join', 'where', 'orderby', 'limits', 'groupby' );
    442442
    443443        /**
     
    449449         * @param WP_Network_Query $query   Current instance of WP_Network_Query (passed by reference).
    450450         */
    451         $clauses = apply_filters_ref_array( 'networks_clauses', array( $clauses, &$this ) );
     451        $clauses = apply_filters_ref_array( 'networks_clauses', array( compact( $clauses ), &$this ) );
    452452
    453453        $fields  = isset( $clauses['fields'] ) ? $clauses['fields'] : '';
  • trunk/src/wp-includes/class-wp-query.php

    r53065 r53175  
    27542754        }
    27552755
    2756         $clauses = compact( 'where', 'groupby', 'join', 'orderby', 'distinct', 'fields', 'limits' );
     2756        $clauses = array( 'where', 'groupby', 'join', 'orderby', 'distinct', 'fields', 'limits' );
    27572757
    27582758        /*
     
    28562856             * @param WP_Query $query   The WP_Query instance (passed by reference).
    28572857             */
    2858             $clauses = (array) apply_filters_ref_array( 'posts_clauses', array( $clauses, &$this ) );
     2858            $clauses = (array) apply_filters_ref_array( 'posts_clauses', array( compact( $clauses ), &$this ) );
    28592859
    28602860            $where    = isset( $clauses['where'] ) ? $clauses['where'] : '';
  • trunk/src/wp-includes/class-wp-site-query.php

    r53107 r53175  
    647647        $where = implode( ' AND ', $this->sql_clauses['where'] );
    648648
    649         $clauses = compact( 'fields', 'join', 'where', 'orderby', 'limits', 'groupby' );
     649        $clauses = array( 'fields', 'join', 'where', 'orderby', 'limits', 'groupby' );
    650650
    651651        /**
     
    657657         * @param WP_Site_Query $query   Current instance of WP_Site_Query (passed by reference).
    658658         */
    659         $clauses = apply_filters_ref_array( 'sites_clauses', array( $clauses, &$this ) );
     659        $clauses = apply_filters_ref_array( 'sites_clauses', array( compact( $clauses ), &$this ) );
    660660
    661661        $fields  = isset( $clauses['fields'] ) ? $clauses['fields'] : '';
  • trunk/src/wp-includes/class-wp-term-query.php

    r52977 r53175  
    693693        $where = implode( ' AND ', $this->sql_clauses['where'] );
    694694
    695         $clauses = compact( 'fields', 'join', 'where', 'distinct', 'orderby', 'order', 'limits' );
     695        $clauses = array( 'fields', 'join', 'where', 'distinct', 'orderby', 'order', 'limits' );
    696696
    697697        /**
     
    704704         * @param array    $args       An array of term query arguments.
    705705         */
    706         $clauses = apply_filters( 'terms_clauses', $clauses, $taxonomies, $args );
     706        $clauses = apply_filters( 'terms_clauses', compact( $clauses ), $taxonomies, $args );
    707707
    708708        $fields   = isset( $clauses['fields'] ) ? $clauses['fields'] : '';
Note: See TracChangeset for help on using the changeset viewer.