[wp-trac] [WordPress Trac] #59826: WP breaks in PHP 8.0 when passing multiple terms of same hiearchichal taxonomy to the query via GET params.

WordPress Trac noreply at wordpress.org
Tue Nov 7 14:17:35 UTC 2023


#59826: WP breaks in PHP 8.0 when passing multiple terms of same hiearchichal
taxonomy to the query via GET params.
-------------------------------+-----------------------------
 Reporter:  lxt                |      Owner:  (none)
     Type:  defect (bug)       |     Status:  new
 Priority:  normal             |  Milestone:  Awaiting Review
Component:  Query              |    Version:  6.3.3
 Severity:  normal             |   Keywords:  needs-patch
  Focuses:  php-compatibility  |
-------------------------------+-----------------------------
 Using WC product_cat as an example here:

 /shop?product_cat%5B%5D=bralettes&product_cat%5B%5D=slips

 This breaks the matrix. In class-wp-query.php we find (LN 1178 - 1180):

 if ( ! empty( $t->rewrite['hierarchical'] ) ) {
   $q[ $t->query_var ] = wp_basename( $q[ $t->query_var ] );
 }

 Because "$q[ $t->query_var ]" is an array holding both terms, not just a
 string.

 My patch: The if query should be changed to avoid running wp_basename on
 arrays:

 if ( ! empty( $t->rewrite['hierarchical'] ) && ! is_array( $q[
 $t->query_var ] ) ) {
   $q[ $t->query_var ] = wp_basename( $q[ $t->query_var ] );
 }

 All the best, LXT

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


More information about the wp-trac mailing list