[wp-trac] [WordPress Trac] #30117: Possible regression in taxonomy.php sanitize_query

WordPress Trac noreply at wordpress.org
Sun Oct 26 22:52:46 UTC 2014


#30117: Possible regression in taxonomy.php sanitize_query
--------------------------+-----------------------------
 Reporter:  tmtrademark   |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Taxonomy      |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 I work in the VIP QuickStart environment, and on updating to the 4.1
 alpha, I believe I may have experienced a regression.

 The following works as expected to modify the query and return posts with
 the extra argument in 4.0

 {{{
 function rt_favorite_exclude_free_listings( $query ) {

         if( $query->is_main_query() && is_tax( 'favorite-category' ) &&
 !$query->get('listings') ) {

                 $tax_query = (array) $query->get( 'tax_query' );

                 $tax_query[] = array(
                         'taxonomy' => 'favorite-type',
                         'field' => 'slug',
                         'terms' => 'premium',
                 );
                 $query->set( 'tax_query', $tax_query );
         }
 }
 add_action( 'pre_get_posts', 'rt_favorite_exclude_free_listings' );
 }}}

 In 4.1, the following errors are thrown:

 {{{
 ( ! ) Warning: array_merge(): Argument #2 is not an array in /srv/www/wp
 /wp-includes/taxonomy.php on line 757
 Call Stack
 #       Time    Memory  Function        Location
 1       0.0062  143404  {main}( )       ../index.php:0
 2       0.0116  145252  require( '/srv/www/wp/wp-blog-header.php' )
 ../index.php:4
 3       5.1287  27041896        wp( )   ../wp-blog-header.php:14
 4       5.1287  27041968        WP->main( )     ../functions.php:873
 5       5.1409  27262256        WP->query_posts( )      ../class-
 wp.php:612
 6       5.1409  27262536        WP_Query->query( )      ../class-
 wp.php:541
 7       5.1409  27264220        WP_Query->get_posts( )  ../query.php:3843
 8       5.1444  27311944        WP_Query->parse_tax_query( )
 ../query.php:2683
 9       5.1446  27313696        WP_Tax_Query->__construct( )
 ../query.php:2026
 10      5.1446  27313724        WP_Tax_Query->sanitize_query( )
 ../taxonomy.php:724
 11      5.1446  27314672        array_merge ( ) ../taxonomy.php:757

 ( ! ) Notice: Undefined index: field in /srv/www/wp/wp-
 includes/taxonomy.php on line 1152
 Call Stack
 #       Time    Memory  Function        Location
 1       0.0062  143404  {main}( )       ../index.php:0
 2       0.0116  145252  require( '/srv/www/wp/wp-blog-header.php' )
 ../index.php:4
 3       5.1287  27041896        wp( )   ../wp-blog-header.php:14
 4       5.1287  27041968        WP->main( )     ../functions.php:873
 5       5.1409  27262256        WP->query_posts( )      ../class-
 wp.php:612
 6       5.1409  27262536        WP_Query->query( )      ../class-
 wp.php:541
 7       5.1409  27264220        WP_Query->get_posts( )  ../query.php:3843
 8       5.1518  27313192        WP_Tax_Query->get_sql( )
 ../query.php:2685
 9       5.1518  27313576        WP_Tax_Query->get_sql_clauses( )
 ../taxonomy.php:857
 10      5.1518  27313892        WP_Tax_Query->get_sql_for_query( )
 ../taxonomy.php:882
 11      5.1518  27315140        WP_Tax_Query->get_sql_for_clause( )
 ../taxonomy.php:933
 12      5.1518  27315760        WP_Tax_Query->clean_query( )
 ../taxonomy.php:1001
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/30117>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list