Make WordPress Core

Opened 7 years ago

Last modified 7 years ago

#48860 reopened defect (bug)

get_queried_object return false when executed in parse_query hook

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

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
7 years ago

  • Component GeneralQuery
  • Milestone Awaiting Review
  • Resolutionduplicate
  • Status newclosed

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

#2 @fliespl
7 years ago

  • Resolution duplicate
  • Status closedreopened

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.