Opened 6 years ago
Closed 6 months ago
#44772 closed enhancement (wontfix)
Optimize `get_the_post_thumbnail_url` call
Reported by: | soulseekah | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Post Thumbnails | Keywords: | has-patch reporter-feedback |
Focuses: | performance | Cc: |
Description
This function merely returns the post meta using the post ID. In cases where an ID is passed there's no need to fetch the complete WP_Post object, use it directly as the post ID in the get_post_meta call.
Attachments (1)
Change History (7)
#2
@
6 years ago
@birgire Eek, cached diff changes from another ticket I was working on. Thanks for noticing! Replaced.
#4
@
6 years ago
- Keywords reporter-feedback added
Hi @soulseekah, thanks for the patch! get_post()
was introduced in [34167].
Do you have any performance benchmarks for this change? get_post()
calls are cached, so I don't expect there to be a huge difference.
The current code has an additional benefit of validating if the post exists before calling get_post_meta()
. With the patch, the return value type changes from an empty string to a boolean false
. This would need to be reflected in the docs and could be a potential back compat issue if someone only accounts for the (currently documented) string value in their code.
It looks like some dbdelta changes came through with the patch.