[wp-trac] [WordPress Trac] #48860: get_queried_object return false when executed in parse_query hook

WordPress Trac noreply at wordpress.org
Tue Dec 3 08:47:54 UTC 2019


#48860: get_queried_object return false when executed in parse_query hook
--------------------------+-----------------------------
 Reporter:  fliespl       |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  5.3
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 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 );
                 }
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/48860>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list