Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#50054 closed defect (bug) (invalid)

Uncaught Error: [] operator not supported for strings >= PHP7.1.0

Reported by: 9re9re's profile 9re9re Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.5
Component: Query Keywords:
Focuses: Cc:

Description

When filtering category with tag via url, say,

http://your.domain/category/blog/?tag=wicked

code reaches here: (I point specific version for future reference but this is also true for the current trunk)
https://core.trac.wordpress.org/browser/branches/5.4/src/wp-includes/class-wp-query.php#L1253

For PHP >= 7.1.0
Array initialization required for [] operator. I personally fixed only this line but code like

<?php
// initialization required: $something = array();
$something[] = 'brabrabra';

is wide spread so I made this ticket for more general solution than my monkey ad hoc patching.
Like make some utility function and use it everywhere.

Change History (3)

#1 @SergeyBiryukov
5 years ago

  • Component changed from General to Query
  • Keywords reporter-feedback added

Hi there, welcome to WordPress Trac! Thanks for the report.

I could not reproduce the issue on a clean install. There is some code in WP_Query::fill_query_var() to make sure every parameter that should be an array is properly initialized as such.

Inspecting the value of $q['tag_slug__in'] just before line 1253 shows that it is in fact an array.

It looks like there is some code on your install that passes a string value to the tag_slug__in parameter.

Does the issue still happen with all plugins disabled and a default theme (Twenty Twenty) activated?

Last edited 5 years ago by SergeyBiryukov (previous) (diff)

#2 @9re9re
5 years ago

  • Resolution set to invalid
  • Status changed from new to closed

@SergeyBiryukov

Thanks for the quick response, I've never tried the default theme, and if tried it works!
So this issue must be related to the theme I'm using and this ticket can be closed.

Thanks.

#3 @SergeyBiryukov
5 years ago

  • Keywords reporter-feedback removed
  • Milestone Awaiting Review deleted

Thanks for the follow-up!

Note: See TracTickets for help on using tickets.