[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
Tue Oct 11 18:13:48 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:  closed
 Priority:  normal                               |   Milestone:  6.1
Component:  Query                                |     Version:  4.0
 Severity:  normal                               |  Resolution:  fixed
 Keywords:  2nd-opinion has-patch has-unit-      |     Focuses:
  tests php8                                     |
-------------------------------------------------+-------------------------
Changes (by SergeyBiryukov):

 * status:  reviewing => closed
 * resolution:   => fixed


Comment:

 In [changeset:"54496" 54496]:
 {{{
 #!CommitTicketReference repository="" revision="54496"
 Query: Avoid PHP notices when `get_queried_object()` returns `null`.

 `WP_Query` methods assume that `get_queried_object()` would return a non-
 null value, which is not always the case.

 This commit resolves various warnings in `WP_Query` along the lines of:
 {{{
 Attempt to read property "post_type" on null in wp-includes/class-wp-
 query.php on line 4338
 }}}

 Follow-up to [1728], [3639], [8807], [49119].

 Props dd32, yellyc, boonebgorges, darkskipper, Howdy_McGee, swissspidy,
 nacin, mikeschroder, mikejolley, sterlo, datainterlock, utsavmadaan823,
 kanlukasz, woji29911, hellofromTonya, zikubd, deksar, bwbama, noplanman,
 nouarah, SergeyBiryukov.
 Fixes #29660.
 }}}

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


More information about the wp-trac mailing list