#63850 closed defect (bug) (fixed)
Avoid doing an extra call to cache/wpdb when post_id is not valid
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 6.9 | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Posts, Post Types | Keywords: | has-patch |
| Focuses: | Cc: |
Description
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.
Attachments (1)
Change History (6)
#2
@
8 months ago
- Component changed from General to Posts, Post Types
- Keywords has-patch added
- Milestone changed from Awaiting Review to 6.9
- Owner set to SergeyBiryukov
- Status changed from new to accepted
Note: See
TracTickets for help on using
tickets.
Props @akeda for the patch.
@SergeyBiryukov could use your input here as well. Thanks a ton 🙏