Changeset 53379
- Timestamp:
- 05/10/2022 04:07:10 PM (3 years ago)
- Location:
- branches/6.0
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/6.0
- Property svn:mergeinfo changed
/trunk merged: 53370,53375
- Property svn:mergeinfo changed
-
branches/6.0/src/wp-includes/class-wp-query.php
r53277 r53379 2755 2755 } 2756 2756 2757 $ clauses = array( 'where', 'groupby', 'join', 'orderby', 'distinct', 'fields', 'limits' );2757 $pieces = array( 'where', 'groupby', 'join', 'orderby', 'distinct', 'fields', 'limits' ); 2758 2758 2759 2759 /* … … 2857 2857 * @param WP_Query $query The WP_Query instance (passed by reference). 2858 2858 */ 2859 $clauses = (array) apply_filters_ref_array( 'posts_clauses', array( compact( $ clauses ), &$this ) );2859 $clauses = (array) apply_filters_ref_array( 'posts_clauses', array( compact( $pieces ), &$this ) ); 2860 2860 2861 2861 $where = isset( $clauses['where'] ) ? $clauses['where'] : ''; … … 2991 2991 * @param WP_Query $query The WP_Query instance (passed by reference). 2992 2992 */ 2993 $clauses = (array) apply_filters_ref_array( 'posts_clauses_request', array( $clauses, &$this ) );2993 $clauses = (array) apply_filters_ref_array( 'posts_clauses_request', array( compact( $pieces ), &$this ) ); 2994 2994 2995 2995 $where = isset( $clauses['where'] ) ? $clauses['where'] : ''; -
branches/6.0/tests/phpunit/tests/query.php
r52822 r53379 720 720 $this->assertSame( get_queried_object_id(), $user_id ); 721 721 } 722 723 /** 724 * Tests that the `posts_clauses` filter receives an array of clauses 725 * with the other `posts_*` filters applied, e.g. `posts_join_paged`. 726 * 727 * @ticket 55699 728 * @covers WP_Query::get_posts 729 */ 730 public function test_posts_clauses_filter_should_receive_filtered_clauses() { 731 add_filter( 732 'posts_join_paged', 733 static function() { 734 return '/* posts_join_paged */'; 735 } 736 ); 737 738 $filter = new MockAction(); 739 add_filter( 'posts_clauses', array( $filter, 'filter' ), 10, 2 ); 740 $this->go_to( '/' ); 741 $filter_args = $filter->get_args(); 742 $posts_clauses = $filter_args[0][0]; 743 744 $this->assertArrayHasKey( 'join', $posts_clauses ); 745 $this->assertSame( '/* posts_join_paged */', $posts_clauses['join'] ); 746 } 747 748 /** 749 * Tests that the `posts_clauses_request` filter receives an array of clauses 750 * with the other `posts_*_request` filters applied, e.g. `posts_join_request`. 751 * 752 * @ticket 55699 753 * @covers WP_Query::get_posts 754 */ 755 public function test_posts_clauses_request_filter_should_receive_filtered_clauses() { 756 add_filter( 757 'posts_join_request', 758 static function() { 759 return '/* posts_join_request */'; 760 } 761 ); 762 763 $filter = new MockAction(); 764 add_filter( 'posts_clauses_request', array( $filter, 'filter' ), 10, 2 ); 765 $this->go_to( '/' ); 766 $filter_args = $filter->get_args(); 767 $posts_clauses_request = $filter_args[0][0]; 768 769 $this->assertArrayHasKey( 'join', $posts_clauses_request ); 770 $this->assertSame( '/* posts_join_request */', $posts_clauses_request['join'] ); 771 } 722 772 }
Note: See TracChangeset
for help on using the changeset viewer.