[wp-trac] [WordPress Trac] #29660: Functions in wp_includes/query.php assume non-null return value from get_queried_object

WordPress Trac noreply at wordpress.org
Thu Aug 4 07:17:52 UTC 2022


#29660: Functions in wp_includes/query.php assume non-null return value from
get_queried_object
-------------------------------------------------+-------------------------
 Reporter:  yellyc                               |       Owner:
                                                 |  SergeyBiryukov
     Type:  defect (bug)                         |      Status:  reviewing
 Priority:  normal                               |   Milestone:  6.1
Component:  Query                                |     Version:  4.0
 Severity:  normal                               |  Resolution:
 Keywords:  2nd-opinion has-patch has-unit-      |     Focuses:
  tests php8                                     |
-------------------------------------------------+-------------------------

Comment (by dd32):

 Replying to [comment:21 boonebgorges]:
 > What does it mean to say `$this->is_category()`? Does it mean that a
 category was *requested*? Or does it mean that you're viewing an actual
 category? The way `WP_Query` currently works, the answer depends on when
 you ask the question:


 And to make it even more complicated, `is_category()` and `is_author()` do
 not necessarily mean they're archives of that type, it can mean that it's
 a singular view but with an additional author/taxonomy check/request (ie.
 https://example.org/post-name/?cat=unknown-cat-slug is both
 `$this->is_singular` and `$this->is_category`, and even though it might
 only resolve to the post, `get_queried_object()` will be `null` as it
 tries to return a category first).

 There's far more problems with the conditionals than just when you call
 them..

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/29660#comment:53>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list