Ticket #55699: 55699.3.diff
| File 55699.3.diff, 2.7 KB (added by , 4 years ago) |
|---|
-
src/wp-includes/class-wp-query.php
2754 2754 } 2755 2755 } 2756 2756 2757 $clauses = array( 'where', 'groupby', 'join', 'orderby', 'distinct', 'fields', 'limits' );2758 2759 2757 /* 2760 2758 * Apply post-paging filters on where and join. Only plugins that 2761 2759 * manipulate paging queries should use these hooks. … … 2835 2833 */ 2836 2834 $fields = apply_filters_ref_array( 'posts_fields', array( $fields, &$this ) ); 2837 2835 2836 $clauses = array( 'where', 'groupby', 'join', 'orderby', 'distinct', 'fields', 'limits' ); 2837 2838 2838 /** 2839 2839 * Filters all query clauses at once, for convenience. 2840 2840 * … … 2967 2967 */ 2968 2968 $limits = apply_filters_ref_array( 'post_limits_request', array( $limits, &$this ) ); 2969 2969 2970 $clauses = array( 'where', 'groupby', 'join', 'orderby', 'distinct', 'fields', 'limits' ); 2971 2970 2972 /** 2971 2973 * Filters all query clauses at once, for convenience. 2972 2974 * … … 2990 2992 * } 2991 2993 * @param WP_Query $query The WP_Query instance (passed by reference). 2992 2994 */ 2993 $clauses = (array) apply_filters_ref_array( 'posts_clauses_request', array( $clauses, &$this ) );2995 $clauses = (array) apply_filters_ref_array( 'posts_clauses_request', array( compact( $clauses ), &$this ) ); 2994 2996 2995 2997 $where = isset( $clauses['where'] ) ? $clauses['where'] : ''; 2996 2998 $groupby = isset( $clauses['groupby'] ) ? $clauses['groupby'] : ''; -
tests/phpunit/tests/query.php
719 719 $this->assertInstanceOf( 'WP_User', get_queried_object() ); 720 720 $this->assertSame( get_queried_object_id(), $user_id ); 721 721 } 722 723 /** 724 * Tests that the `posts_clauses_request` filter receives an array of clauses 725 * with the other `posts_*_request` filters applied, e.g. `posts_join_request`. 726 * 727 * @ticket 55699 728 * @covers WP_Query::get_posts 729 */ 730 public function test_posts_clauses_request_filter_should_receive_filtered_clauses() { 731 add_filter( 732 'posts_join_request', 733 static function() { 734 return '/* posts_join_request */'; 735 } 736 ); 737 738 $filter = new MockAction(); 739 add_filter( 'posts_clauses_request', array( $filter, 'filter' ), 10, 2 ); 740 $this->go_to( '/' ); 741 $filter_args = $filter->get_args(); 742 $posts_clauses_request = $filter_args[0][0]; 743 744 $this->assertArrayHasKey( 'join', $posts_clauses_request ); 745 $this->assertSame( '/* posts_join_request */', $posts_clauses_request['join'] ); 746 } 722 747 }