[wp-trac] [WordPress Trac] #18822: get_permalink() produces an add. DB request without $post->filter

WordPress Trac wp-trac at lists.automattic.com
Fri Sep 30 12:57:48 UTC 2011


#18822: get_permalink() produces an add. DB request without $post->filter
-------------------------+------------------------------
 Reporter:  F J Kaiser   |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Performance  |     Version:  3.2.1
 Severity:  major        |  Resolution:
 Keywords:  needs-patch  |
-------------------------+------------------------------

Comment (by F J Kaiser):

 Replying to [comment:2 duck_]:
 > In fact get_post() will only perform a query if you pass an object when
 the object has the filter property set ''and'' that post ID isn't already
 cached.

 If you look closer at the code (in core & on wpse) you'll see that there's
 the filter name 'sample' required. Default is 'raw'. So, until you don't
 set the filter to 'sample' manually, you'll get an additional query.

 > You can also pass the whole $post object to get_permalink for no extra
 queries as get_post() accepts an object.

 Sure, but it won't be used until the object hasn't got the appropriate
 ''filter'' attached.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/18822#comment:5>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list