multi-db: small bug in analyze_query()

This is a little bit of a nit… and since I absolutely hate regex, I won’t dare to propose a fix. But I just discovered a small bug in analyze_query() that fails to properly pick out some legitimate SELECT queries. It has something to do with analyze_query() wanting a space before the FROM of the SELECT query.

So, for example, the following SQL is perfectly legitimate SQL, but analyze_query() has a problem getting the right database for it.

$viewstoday = (int) $wpdb->get_var("SELECT COUNT(1)FROM $postviews_table WHERE (date_stamp = '$today_date') $admins_for_blog_filter");

Notice that the “:wink:” is right next to the “FROM” with no space. This is legitimate SQL but it apparently slips through the cracks of analyze_query().

If fixed our system by adding a space.

Like I said I’m not regex pro… in fact I hate regex… but I think the issue may be related to the “s+FROM” + requiring at least one whitespace… where in fact that’s more restrictive than SQL really is.

I imagine this same issue exists with the other query types as well.

Anyway, just thought you’d like to know.