Home > Things Lunix > Found the bug.

Found the bug.

August 19th, 2007 ola Leave a comment Go to comments

When getting the list of blog entries, this select is executed:

SELECT SQL_CALC_FOUND_ROWS  wp_posts.*
FROM wp_posts
LEFT JOIN wp_postmeta ON wp_postmeta.post_id = wp_posts.ID
WHERE 1=1  AND (post_type = ‘post’ AND (post_status = ‘publish’))
  AND ((wp_postmeta.meta_key != ‘wpicasa_imgfilename’
  AND wp_postmeta.meta_key != ‘wpicasa_album’ AND wp_postmeta.meta_key != ‘wpicasa_folder’) OR wp_postmeta.meta_key IS NULL)
ORDER BY post_date DESC LIMIT 0, 5

For some reason the newest WP adds two rows in wp_postmeta per post.

mysql> select * from wp_postmeta where post_id = 171;
+———+———+————+————+
| meta_id | post_id | meta_key  | meta_value |
+———+———+————+————+
|    219 |    171 | _pingme    | 1          |
|    220 |    171 | _encloseme | 1          |
+———+———+————+————+
2 rows in set (0.00 sec)

This leads to getting two duplicate rows back from the query. I solved this by patching the code, adding a DISTINCT after the SELECT. My bet is that this is some trouble with some weirdo plugin or whatnot, so I’ll just let it slide..

Categories: Things Lunix Tags:
  1. May 9th, 2008 at 13:41 | #1

    I don’t find this text in wp_postmeta in WP v2.0.3.