BUG: HyperDB breaking a "SELECT FOUND_ROWS()" query with alias
-
One of the plugins we’re using (Custom Content Type Manager) when doing pagination, is doing a simple “SELECT FOUND_ROWS()” query, except they’re using a “as cnt” alias.
This was breaking for us when we were using the theme with a WPengine install, but not with our own builds.
After some investigation, I found that hyperdb overrides the basic wordpress query function in wp-content/db.php, and in the new function, it specifically looks for “SELECT FOUND_ROWS()” queries and seems to cache the results, probably for optimization. The problem is, when it finds these queries, it does not capture possible aliases and pass them through to the final result.
In short, the plugin was doing this:
SELECT FOUND_ROWS() as cnt
and expecting:
array('cnt' => '12345')
but was receiving
array('FOUND_ROWS()' => '12345')
so it assumed ‘cnt’ as ‘null’ and does not build any pagination.
- The topic ‘BUG: HyperDB breaking a "SELECT FOUND_ROWS()" query with alias’ is closed to new replies.