Opened 3 years ago
Closed 6 weeks ago
#42949 closed enhancement (invalid)
wp_attachment_is() forces the page to get new instance of post
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Posts, Post Types | Keywords: | reporter-feedback close |
Focuses: | performance | Cc: |
Description
In the wp_attachment_is function, the signature allows for the post to be passed in as either ID or object. However, if you pass and an instance of a post object in, the current code forces you to retrieve another copy of the post object. It should use the object passed in to prevent unnecessary database calls.
Change History (3)
#3
@
6 weeks ago
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
Hello @bowlerman235 and Welcome to Trac!
I'm closing this ticket you opened. Why? It's been over 3 years since feedback was requested.
However, please feel free to reopen and provide us with feedback. Cheers.
Note: See
TracTickets for help on using
tickets.
Hi @bowlerman235,
wp_attachment_is()
does make a call toget_post()
however in the event that a WP_Post is passed it'll eventually get passed back. WordPress also includes a in-memory cache so that fetching the same post multiple times by the same ID will not result in more database queries.If you're seeing something other than the above, can you let us know exactly what you're seeing?
This ticket seems
invalid
, however I'll wait for your response before closing it for now.