[wp-trac] [WordPress Trac] #44772: Optimize `get_the_post_thumbnail_url` call

WordPress Trac noreply at wordpress.org
Sat Aug 11 14:18:11 UTC 2018


#44772: Optimize `get_the_post_thumbnail_url` call
-----------------------------------------+------------------------------
 Reporter:  soulseekah                   |       Owner:  (none)
     Type:  enhancement                  |      Status:  new
 Priority:  normal                       |   Milestone:  Awaiting Review
Component:  Post Thumbnails              |     Version:
 Severity:  normal                       |  Resolution:
 Keywords:  has-patch reporter-feedback  |     Focuses:  performance
-----------------------------------------+------------------------------
Changes (by SergeyBiryukov):

 * keywords:  has-patch => has-patch reporter-feedback


Comment:

 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.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/44772#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list