[wp-trac] [WordPress Trac] #62287: WP_REST_Posts_Controller::prepare_items_query() - Warning $prepared_args can be null
WordPress Trac
noreply at wordpress.org
Mon Feb 23 18:37:24 UTC 2026
#62287: WP_REST_Posts_Controller::prepare_items_query() - Warning $prepared_args
can be null
--------------------------+------------------------------
Reporter: apermo | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: REST API | Version: 4.7
Severity: normal | Resolution:
Keywords: has-patch | Focuses:
--------------------------+------------------------------
Comment (by dmsnell):
thanks for sharing this report @apermo — I can only guess that some custom
code implementing the `rest_{$this->post_type}_query` is returning `NULL`,
which then gets sent into `prepare_items_query()`
because of that, and because it’s `protected`/private, I feel like it
could be more reasonable to fix the call sites, defaulting `NULL` values
to `array()` before sending them to the method. why? this is coherent with
the existing types, which state that the argument //must// be an `array`,
and while it’s optional, that does not permit sending a `NULL` value —
only in //sending no values//.
open to thoughts here. if this were more exposed to plugin and theme
authors as part of a public interface I would probably favor adding more
guards internally, but in doing so we create a inconsistency in the code
between the types and the expectations.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/62287#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list