Skip to content

Query Vars II: Modify after pre_get_posts. #8685

New issue

Have a question about this project? Sign up for a free account to open an issue and contact its maintainers and the community.

By clicking “Sign up for ”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on ? Sign in to your account

Draft
wants to merge 10 commits into
base: trunk
Choose a base branch
from
PrevPrevious commit
Next Next commit
Consistent names.
  • Loading branch information
@peterwilsoncc
peterwilsoncc committedApr 14, 2025
commit 511048841f5464d29a27b2e9e7c8b5bde0372ee7
110 changes: 55 additions & 55 deletions tests/phpunit/tests/query/thePost.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -452,61 +452,61 @@ function ( $query ) use ( $query_var, $query_var_value, &$number_action_runs ) {
*/
public function data_pre_get_posts_includes_unmodified_query_vars() {
return array(
'post type, string' => array( 'post_type', 'post' ),
'post type, DESC array' => array( 'post_type', array( 'post', 'page' ) ),
'post type, ASC array' => array( 'post_type', array( 'page', 'post' ) ),
'post type, duplicate array' => array( 'post_type', array( 'post', 'post' ) ),
'post status, string' => array( 'post_status', 'publish' ),
'post status, DESC array' => array( 'post_status', array( 'publish', 'draft' ) ),
'post status, ASC array' => array( 'post_status', array( 'draft', 'publish' ) ),
'post status, duplicate array' => array( 'post_status', array( 'draft', 'draft' ) ),

'post_name__in, string' => array( 'post_name__in', 'elphaba' ),
'post_name__in, DESC array' => array( 'post_name__in', array( 'the-wizard-of-oz', 'glinda', 'doctor-dillamond', 'elphaba' ) ),
'post_name__in, ASC array' => array( 'post_name__in', array( 'elphaba', 'doctor-dillamond', 'glinda', 'the-wizard-of-oz' ) ),
'post_name__in, array dupes' => array( 'post_name__in', array( 'elphaba', 'doctor-dillamond', 'elphaba', 'doctor-dillamond' ) ),

'category__in, int[] ASC' => array( 'category__in', array( 1, 2 ) ),
'category__in, int[] DESC' => array( 'category__in', array( 2, 1 ) ),

'post id, int' => array( 'p', 1 ),
'page_id, int' => array( 'page_id', 1 ),
'attachment_id, int' => array( 'page_id', 1 ),
'offset, string' => array( 'offset', '5' ),
'offset, int' => array( 'offset', 5 ),

'post__in, string[] ASC' => array( 'post__in', array( '1', '2' ) ),
'post__in, string[] DESC' => array( 'post__in', array( '2', '1' ) ),
'post__in, int[] ASC' => array( 'post__in', array( 1, 2 ) ),
'post__in, int[] DESC' => array( 'post__in', array( 2, 1 ) ),
'post__in, int[] duplicate' => array( 'post__in', array( 1, 1 ) ),

'post__not_in, string[] ASC' => array( 'post__not_in', array( '1', '2' ) ),
'post__not_in, string[] DESC' => array( 'post__not_in', array( '2', '1' ) ),
'post__not_in, int[] ASC' => array( 'post__not_in', array( 1, 2 ) ),
'post__not_in, int[] DESC' => array( 'post__not_in', array( 2, 1 ) ),
'post__not_in, int[] duplicate' => array( 'post__not_in', array( 1, 1 ) ),

'author__in, string[] ASC' => array( 'author__in', array( '1', '2' ) ),
'author__in, string[] DESC' => array( 'author__in', array( '2', '1' ) ),
'author__in, int[] ASC' => array( 'author__in', array( 1, 2 ) ),
'author__in, int[] DESC' => array( 'author__in', array( 2, 1 ) ),
'author__in, int[] duplicate' => array( 'author__in', array( 1, 1 ) ),

'author__not_in, string[] ASC' => array( 'author__not_in', array( '1', '2' ) ),
'author__not_in, string[] DESC' => array( 'author__not_in', array( '2', '1' ) ),
'author__not_in, int[] ASC' => array( 'author__not_in', array( 1, 2 ) ),
'author__not_in, int[] DESC' => array( 'author__not_in', array( 2, 1 ) ),
'author__not_in, int[] duplicate' => array( 'author__not_in', array( 1, 1 ) ),

'tag_slug__in, string[] ASC' => array( 'tag_slug__in', array( 'bobby', 'hans', 'herman', 'victor' ) ),
'tag_slug__in, string[] DESC' => array( 'tag_slug__in', array( 'victor', 'herman', 'hans', 'bobby' ) ),

'tag__in, int[] ASC' => array( 'tag__in', array( 1, 2 ) ),
'tag__in, int[] DESC' => array( 'tag__in', array( 2, 1 ) ),

'tag__not_in, int[] ASC' => array( 'tag__not_in', array( 1, 2 ) ),
'tag__not_in, int[] DESC' => array( 'tag__not_in', array( 2, 1 ) ),
'post type, string' => array( 'post_type', 'post' ),
'post type, string[] DESC' => array( 'post_type', array( 'post', 'page' ) ),
'post type, string[] ASC' => array( 'post_type', array( 'page', 'post' ) ),
'post type, string[] duplicate' => array( 'post_type', array( 'post', 'post' ) ),
'post status, string' => array( 'post_status', 'publish' ),
'post status, string[] DESC' => array( 'post_status', array( 'publish', 'draft' ) ),
'post status, string[] ASC' => array( 'post_status', array( 'draft', 'publish' ) ),
'post status, string[] duplicate' => array( 'post_status', array( 'draft', 'draft' ) ),

'post_name__in, string' => array( 'post_name__in', 'elphaba' ),
'post_name__in, string[] DESC' => array( 'post_name__in', array( 'the-wizard-of-oz', 'glinda', 'doctor-dillamond', 'elphaba' ) ),
'post_name__in, string[] ASC' => array( 'post_name__in', array( 'elphaba', 'doctor-dillamond', 'glinda', 'the-wizard-of-oz' ) ),
'post_name__in, string[] duplicate' => array( 'post_name__in', array( 'elphaba', 'doctor-dillamond', 'elphaba', 'doctor-dillamond' ) ),

'category__in, int[] ASC' => array( 'category__in', array( 1, 2 ) ),
'category__in, int[] DESC' => array( 'category__in', array( 2, 1 ) ),

'post id, int' => array( 'p', 1 ),
'page_id, int' => array( 'page_id', 1 ),
'attachment_id, int' => array( 'page_id', 1 ),
'offset, string' => array( 'offset', '5' ),
'offset, int' => array( 'offset', 5 ),

'post__in, string[] ASC' => array( 'post__in', array( '1', '2' ) ),
'post__in, string[] DESC' => array( 'post__in', array( '2', '1' ) ),
'post__in, int[] ASC' => array( 'post__in', array( 1, 2 ) ),
'post__in, int[] DESC' => array( 'post__in', array( 2, 1 ) ),
'post__in, int[] duplicate' => array( 'post__in', array( 1, 1 ) ),

'post__not_in, string[] ASC' => array( 'post__not_in', array( '1', '2' ) ),
'post__not_in, string[] DESC' => array( 'post__not_in', array( '2', '1' ) ),
'post__not_in, int[] ASC' => array( 'post__not_in', array( 1, 2 ) ),
'post__not_in, int[] DESC' => array( 'post__not_in', array( 2, 1 ) ),
'post__not_in, int[] duplicate' => array( 'post__not_in', array( 1, 1 ) ),

'author__in, string[] ASC' => array( 'author__in', array( '1', '2' ) ),
'author__in, string[] DESC' => array( 'author__in', array( '2', '1' ) ),
'author__in, int[] ASC' => array( 'author__in', array( 1, 2 ) ),
'author__in, int[] DESC' => array( 'author__in', array( 2, 1 ) ),
'author__in, int[] duplicate' => array( 'author__in', array( 1, 1 ) ),

'author__not_in, string[] ASC' => array( 'author__not_in', array( '1', '2' ) ),
'author__not_in, string[] DESC' => array( 'author__not_in', array( '2', '1' ) ),
'author__not_in, int[] ASC' => array( 'author__not_in', array( 1, 2 ) ),
'author__not_in, int[] DESC' => array( 'author__not_in', array( 2, 1 ) ),
'author__not_in, int[] duplicate' => array( 'author__not_in', array( 1, 1 ) ),

'tag_slug__in, string[] ASC' => array( 'tag_slug__in', array( 'bobby', 'hans', 'herman', 'victor' ) ),
'tag_slug__in, string[] DESC' => array( 'tag_slug__in', array( 'victor', 'herman', 'hans', 'bobby' ) ),

'tag__in, int[] ASC' => array( 'tag__in', array( 1, 2 ) ),
'tag__in, int[] DESC' => array( 'tag__in', array( 2, 1 ) ),

'tag__not_in, int[] ASC' => array( 'tag__not_in', array( 1, 2 ) ),
'tag__not_in, int[] DESC' => array( 'tag__not_in', array( 2, 1 ) ),
);
}
}
Loading