Make WordPress Core

Opened 5 years ago

Last modified 5 years ago

#48860 reopened defect (bug)

get_queried_object return false when executed in parse_query hook

Reported by: fliespl's profile fliespl Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.3
Component: Query Keywords:
Focuses: Cc:

Description

When this function is executed in parse_query hook (i.e. woocommerce-perfect-seo-url) on author page ( /author/XXX/ ) it results with this notice.

#13 E_NOTICE: Trying to get property 'ID' of non-object

It's because 'author_name' is not converted into 'author' field in parse_query.

It's only used to mark page as "is_author".

			if ( '' != $qv['author_name'] ) {
				$this->is_author = true;
			}

And get_queried_object relies on 'author' variable.

		} elseif ( $this->is_author ) {
			$this->queried_object_id = (int) $this->get( 'author' );
			$this->queried_object    = get_userdata( $this->queried_object_id );
		}

Change History (2)

#1 @SergeyBiryukov
5 years ago

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

Thanks for the ticket, we're already tracking this issue in #29660.

#2 @fliespl
5 years ago

  • Resolution duplicate deleted
  • Status changed from closed to reopened

I have seen this thread and I am pretty sure this issue is not handled there.

Thread you mention is about usage of function that might return null.

Issue described here is about proper population of object information in get_queried_object and get_queried_object_id functions.

I am re-opening it as I have a feeling it's totally different issue.

Note: See TracTickets for help on using tickets.