Quantcast
Channel: Rather Curious ... » Sqlite
Viewing all articles
Browse latest Browse all 10

PDO For WordPress v1.0.0: Already a bug!!

$
0
0

Nanxiao just posted a comment here. Having originally thought this was due to a badly behaved plugin, i’ve just looked at it myself again. most of the routes to comment moderation work (i.e. direct clicking on the email link, going to comments through a manage-posts screen etc).

However, it is correct that the comments do not natively show up in the manage comments list. from wp 2.5.1.

This seems to be because the authors have started to use index hints in the sql – this is annoying and another example of non-standard sql!

The queries that are executed are these:

SELECT comment_approved, COUNT( * ) AS num_comments FROM wp_comments GROUP BY comment_approved
 
SELECT  COUNT(*) FROM  wp_comments USE INDEX (comment_date_gmt) WHERE ( comment_approved = '0' OR comment_approved = '1' ) ORDER BY comment_date_gmt DESC
 
SELECT SQL_CALC_FOUND_ROWS * FROM wp_comments USE INDEX (comment_date_gmt) WHERE ( comment_approved = '0' OR comment_approved = '1' ) ORDER BY comment_date_gmt DESC LIMIT 0, 25

Personally I don’t see why all these queries are needed (but i have not looked at it closely). I don’t see why we need to have an order by clause on a select count(*) query and i don’t see why you need the second query when the third query gives you the same information.

Anyway, the problem comes in the USE INDEX () syntax, which is required by mysql for index hinting but is either not required or not supported by sqlite.

The good news is that this is an easy fix which I will post later todayhave already posted. In the meantime, the other routes to comment moderation will function.

Thanks to Nanxiao for spotting this and pointing it out.


Viewing all articles
Browse latest Browse all 10

Trending Articles