[wp-trac] [WordPress Trac] #63850: Avoid doing an extra call to cache/wpdb when post_id is not valid
WordPress Trac
noreply at wordpress.org
Wed Aug 20 13:41:15 UTC 2025
#63850: Avoid doing an extra call to cache/wpdb when post_id is not valid
--------------------------+-----------------------------
Reporter: bor0 | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
While investigating an issue on WooCommerce.com, we discovered that some
plugins invoke `WP_Post::get_instance( -1 )`.
Although one could argue this is a plugin-level problem, we noticed that
WordPress still processes the request and unnecessarily performs calls to
`wp_cache_get` and `wpdb->get_row`.
We propose adding a short-circuit to handle cases where `post_id` is
negative, not just when it equals zero.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63850>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list