Make WordPress Core

Opened 14 months ago

Closed 6 months ago

#59826 closed defect (bug) (duplicate)

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: 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 (8)

#1 @jrf
14 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
14 months ago

Duplicate of #57300 ?

#3 @lxt
12 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 12 months ago by lxt (previous) (diff)

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


12 months ago
#4

  • Keywords has-patch added; needs-patch removed

#5 @petitphp
12 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
12 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:


12 months ago
#7

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

So we can close this PR.

#8 @dd32
6 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #57300.

Note: See TracTickets for help on using tickets.