[wp-trac] [WordPress Trac] #28425: get_permalink passes only post ID to called functions instead of post object
WordPress Trac
noreply at wordpress.org
Tue Jun 3 15:28:12 UTC 2014
#28425: get_permalink passes only post ID to called functions instead of post
object
-------------------------------+--------------------------
Reporter: arnee | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: 4.0
Component: Posts, Post Types | Version: trunk
Severity: normal | Resolution:
Keywords: has-patch | Focuses: performance
-------------------------------+--------------------------
Comment (by arnee):
A case like this would be if you have a post object, which is not in the
post cache yet. There might be several reasons for this, one is if you
used a custom SELECT SQL to fetch more than one post (like my sitemap
plugin does).
On the get_permalink call, the first get_post call will transform the
given object into a WP_Post object. This is good. Unfortunately if the
post is a page, ''get_page_link'' will be called with only the ID.
get_page_link therefore calls get_post (with only the ID) which leads to a
SQL query.
Anyway there is no reason the object should not be passed, since passing
the ID creates definitely ''some'' unnecessary overhead in any case.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/28425#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list