[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 24 16:31:31 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):

 kovshenin, this example was very very simple just to demonstrate the
 behavior. In the actual case I would of course not query a single post,
 but probably 100, 200 or more.
 Regarding your suggestions:
 - WP_Query is not a solution, since other plugins will break the query
 with their filters. WP_Query with suppress_filters is not a solution,
 since I would need to use my own filters to get the result I want. I've
 tried it before and it was a huge unreliable mess.
 - As long as a persitent cache is not part of WP Core, the probability
 that the posts are in the cache is zero. It has to work for all WP sites
 not for the 1% which run a persistent object cache.

 The additional db query can avoided by just using the available objects
 instead of the ID. I think the change is pretty simple and makes sense, it
 actually saves some CPU. There is no reason for throwing away the object
 and passing the ID just to get the object from the cache again.

 Actually, the get_instance method of WP_Post (which is called by get_post
 if your only use the ID) will even create a new WP_Post object every time
 it is read from the cache, since the cache contains the raw data and not
 the WP_Post object.

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


More information about the wp-trac mailing list