[wp-trac] [WordPress Trac] #28425: get_permalink passes only post ID to called functions instead of post object

WordPress Trac noreply at wordpress.org
Wed Jun 25 03:14:09 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 dev-feedback close  |     Focuses:  performance
------------------------------------------+--------------------------
Changes (by rmccue):

 * keywords:  has-patch dev-feedback => has-patch dev-feedback close


Comment:

 Replying to [comment:6 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).

 If you're doing a custom SELECT, then you should be calling
 `update_post_cache()` (or `update_post_caches()`) on the posts to ensure
 they're added to the cache. You should be doing this regardless of how WP
 behaves internally. (Even if you don't have an external object cache, this
 will still cache them in memory for the current request.)

 Apart from that, I'd ''still'' recommend using WP_Query if at all
 possible. You note "WP_Query is not a solution, since other plugins will
 break the query with their filters", but I'm not sure exactly what would
 be actually conflicting here.

 I'm not sure that changing `get_permalink()` behaviour really gains us
 anything here. Seems like unnecessary code churn to me. Recommend close.

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


More information about the wp-trac mailing list