Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#57587 closed defect (bug) (invalid)

Method get_term_link() isn't type safe - (Attempt to read property "query_var" on bool)

Reported by: 1benk1 Owned by:
Priority: normal Milestone:
Component: Taxonomy Version: 6.1.1
Severity: normal Keywords:
Cc: Focuses:

Description

Within wp-includes/taxonomy.php the method get_term_link() is dropping following error in the monitoring:

PHP Warning: Attempt to read property "query_var" on bool in /wp-includes/taxonomy.php on line 4590 (​https://github.com/WordPress/WordPress/blob/master/wp-includes/taxonomy.php#L4590)

Change History (7)

#1 @costdev
4 years ago

  • Component General → Taxonomy

#2 @costdev
4 years ago

  • Keywords reporter-feedback added

Hi @1benk1, welcome to Trac and thanks for opening this ticket!

Can you please provide steps to reproduce this warning? Thanks!

#3 @1benk1
4 years ago

Unfortunately, not in the moment. We run a large website with WordPress and this message popped up in our monitoring immediately after a recent switch to PHP 8.1.

I suspect that the call to get_taxonomy() in line 4584 (​https://github.com/WordPress/WordPress/blob/master/wp-includes/taxonomy.php#L4584) returns false and access to a boolean is not allowed, as is the case in line 4590.

I'm trying to figure out under what circumstances the return value of get_taxonomy() in this method can be false and reproduce the whole thing.

Actually, the only conceivable case is that a WP_Term object is passed to get_term_link() whose taxonomy property does not really exist.

#4 @1benk1
4 years ago

  • Resolution → wontfix
  • Status new → closed

After some debugging I found out that $term is not a WP_Term object, but the MultipleAuthors\Classes\Objects\Author class of a plugin (​https://github.com/publishpress/PublishPress-Authors/blob/development/src/core/Classes/Objects/Author.php).

We used get_term_link() with the return value of get_queried_object() (​https://developer.wordpress.org/reference/functions/get_queried_object/) and the documenation of this Method is suggesting, that the return values can only be WP_Term|WP_Post_Type|WP_Post|WP_User|null.

This report can be closed...

#5 @knutsp
4 years ago

  • Keywords reporter-feedback removed
  • Resolution wontfix
  • Status closed → reopened
  • Summary Method get_term_link() isn't type save - (Attempt to read property "query_var" on bool) → Method get_term_link() isn't type safe - (Attempt to read property "query_var" on bool)

#6 @knutsp
4 years ago

  • Resolution → invalid
  • Status reopened → closed

#7 @SergeyBiryukov
4 years ago

  • Milestone Awaiting Review
Note: See TracTickets for help on using tickets.