[wp-trac] [WordPress Trac] #57300: parse_tax_query() does not handle array query param when taxonomy has rewrite set to hierarchical
WordPress Trac
noreply at wordpress.org
Fri Dec 9 06:23:37 UTC 2022
#57300: parse_tax_query() does not handle array query param when taxonomy has
rewrite set to hierarchical
---------------------------+-----------------------------
Reporter: chamois_blanc | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Taxonomy | Version: 6.1.1
Severity: major | Keywords:
Focuses: |
---------------------------+-----------------------------
Accessing the following URL on one of my sites create a PHP 8 type error:
/calendar/list/?tribe_events_cat[0]=advertised
tribe_events_cat is a taxonomy associated with the tribe_events custom
post type. It is defined with rewrite as hierarchical.
The code in `parse_tax_query()` does not seem to handle this case
properly. If rewrite is not set to hierarchical, the code checks whether
the query term is an array and implodes it:
{{{#!php
<?php
$term = $q[ $t->query_var ];
if ( is_array( $term ) ) {
$term = implode( ',', $term );
}
}}}
but if rewrite is set to hierarchical, the term is passed to
`wp_basename()` directly. I don't know much about this code, but it seems
like a bug.
Here is the code trace:
{{{
[ERROR] lvl:1 | msg:Uncaught TypeError: urlencode(): Argument #1 ($string)
must be of type string, array given in .../public_html/wp-
includes/formatting.php:5525
Stack trace:
#0 .../public_html/wp-includes/formatting.php(5525): urlencode()
#1 .../public_html/wp-includes/class-wp-query.php(1166): wp_basename()
#2 .../public_html/wp-includes/class-wp-query.php(936):
WP_Query->parse_tax_query()
#3 .../public_html/wp-includes/class-wp-query.php(1820):
WP_Query->parse_query()
#4 .../public_html/wp-includes/class-wp-query.php(3749):
WP_Query->get_posts()
#5 .../public_html/wp-includes/class-wp.php(663): WP_Query->query()
#6 .../public_html/wp-includes/class-wp.php(783): WP->query_posts()
#7 .../public_html/wp-includes/functions.php(1332): WP->main()
#8 .../public_html/wp-blog-header.php(16): wp()
#9 .../public_html/index.php(17): require('...')
#10 {main}
thrown | file:.../public_html/wp-includes/formatting.php | ln:5525
}}}
It does not appear to go through any theme/plugins code, so my guess is
that it's a WP core bug. Let me know if I'm getting this wrong.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/57300>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list