﻿id,summary,reporter,owner,description,type,status,priority,milestone,component,version,severity,resolution,keywords,cc
18822,get_permalink() produces an add. DB request without $post->filter,F J Kaiser,ryan,"When used in a Query-Loop, `get_permalink()` makes an additional query  `$post = &get_post($id);` to produce a valid link to the post (in example: archive pages). This means that you'll get one additional query ''per'' post-permalink on your archive page, which can pretty fast sum up.

When looking at [http://core.trac.wordpress.org/browser/trunk/wp-includes/link-template.php?annotate=blame&rev=18328#L95 link-template.php line 95], you can see the `if`/`else` statement that avoids throwing a complete `$post` object into the function to produce a permalink without an additional query. 

''The exact line that prevents using the post object:''
{{{
if ( is_object($id) && isset($id->filter) && 'sample' == $id->filter ) {
}}}

So far the only possible solutions that can prevent that behaviour are shown in this [http://wordpress.stackexchange.com/questions/28933/why-does-get-permalink-produces-an-add-db-request-without-post-filter Q on WordPress StackExchange] - see ''answer by Scribu'' & ''Edit 3 by myself''. 

I haven't tested this for a patch, but maybe replacing the line with 
{{{
if ( is_object($id) XOR (isset($id->filter) && 'sample' === $id->filter) ) {
}}}
would be enough, to make both the test cases/samples work as well as to prevent the additional query.

As adding a permalink to a post on archive pages is pretty common, I'd say this could be close to a major perfomance increase for WordPress Loops.",defect (bug),closed,normal,3.3,Performance,3.2.1,normal,fixed,has-patch,solaris.smoke@… 24-7@…
