[wp-trac] [WordPress Trac] #42335: NULL get_queried_object on /feed URL

WordPress Trac noreply at wordpress.org
Wed Oct 25 16:23:04 UTC 2017


#42335: NULL get_queried_object on /feed URL
--------------------------+-----------------------------
 Reporter:  krbvroc1      |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Query         |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 I have been trying to track down numerous PHP notices littering my log
 files. I have traced it to when someone fetches a /feed version of a
 page/post. When this happens the various conditionals such as
 is_singular(), is_single(), is_page(), etc call

 {{{
 $post_obj = $this->get_queried_object();
 }}}

 which returns NULL. Then the WP routines try to reference the post_type
 which throws a notice such as:
 PHP Notice:  Trying to get property of non-object in /opt/www/wp-includes
 /class-wp-query.php on line 3895

 Woocommerce for example uses template_redirect and checks is_page() or
 is_singular() which throws a bunch of notices.

 WP_Query does have an is_feed variable that is set...perhaps it could use
 that as a check before it tries to access a null object.

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


More information about the wp-trac mailing list