Make WordPress Core

Opened 7 months ago

Last modified 5 months ago

#59826 new defect (bug)

WP breaks in PHP 8.0 when passing multiple terms of same hiearchichal taxonomy to the query via GET params.

Reported by: lxt's profile lxt Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 6.3.3
Component: Query Keywords: php80 has-patch
Focuses: Cc:

Description

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->rewritehierarchical? ) ) {

$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->rewritehierarchical? ) && ! is_array( $q[ $t->query_var ] ) ) {

$q[ $t->query_var ] = wp_basename( $q[ $t->query_var ] );

}

All the best, LXT

Change History (7)

#1 @jrf
7 months ago

  • Focuses php-compatibility removed
  • Keywords php80 added

Hi @lxt Thanks for bringing this to our attention and welcome to Trac.

What error specifically are your seeing ? It may also be helpful to add a backtrace for the error to the ticket.

#2 @skithund
7 months ago

Duplicate of #57300 ?

#3 @lxt
5 months ago

Yes, @skithund it is a duplication of #57300. Sorry for not seeing that ticket.

And sorry @jrf for not getting back to your question earlier.

Can we fix this now in the core? Otherwise, I have to disable automatic updates and manually update and fix the core upon every update like @chamois_blanc wrote in #57300 - which is annoying of course.

Last edited 5 months ago by lxt (previous) (diff)

This ticket was mentioned in PR #5889 on WordPress/wordpress-develop by @lxt.


5 months ago
#4

  • Keywords has-patch added; needs-patch removed

#5 @petitphp
5 months ago

Hi @lxt, thanks for the ticket.

#57300 has a patch that should fix this issue. Can you try it and see if it's working for you (https://github.com/WordPress/wordpress-develop/pull/4396) ?

We can close this ticket afterward if the patch in #57300 fix this issue.

#6 @lxt
5 months ago

Hi @petitphp,

that's very nice. I have to admit that the pull request that you've quoted is better than my own. So I agree to close this ticket and remove my own pull request. However please somebody make sure that https://github.com/WordPress/wordpress-develop/pull/4396 will be merged into the trunk ASAP.

Love to all who contributed here, all the best,
Alex T.

@lxt commented on PR #5889:


5 months ago
#7

Sorry this is a duplication of https://github.com/WordPress/wordpress-develop/pull/4396

So we can close this PR.

Note: See TracTickets for help on using tickets.