[wp-hackers] Please revise get_postdata
Paul Findlay
p_findlay1 at clear.net.nz
Fri Feb 4 00:15:24 GMT 2005
Since the 2005-02-02 nightly I noticed that user_can_edit_post() (in
functions-post.php) is now used by edit_post_link() (in
template-functions-links.php). The implication's of this are:
- for each post edit_post_link() is called
- for each post edit_post_link() call, user_can_edit_post() is called
- for each user_can_edit_post() call, get_postdata() (from
functions.php) is called.
- for each get_postdata() a database query (around line 528) is made.
this last point is where the problems arise. It is usually quite
unnecessary (the data is already there in the loop) and can in most
cases be eliminated by a simple if statement before hand (I think):
if(!$post || $postid != $post->ID)
$post = $wpdb->get_row(...);
I'm new at this and can't make patches, so I hope this makes sense. I
was wondering why the number of database queries had dramatically
increased and traced it to the get_postdata() function. This fixes is it
for me.
Is my fix worthy of your attention? I hope so, but in future should I
make bug reports first?
Thanks,
- Paul
More information about the hackers
mailing list