Hi, I'm using views content cache in a site I have recently build and it seems to work great, but in my site log there are a lot of php errors:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')) ORDER BY timestamp DESC' at line 1 query: SELECT timestamp FROM views_content_cache WHERE (()) ORDER BY timestamp DESC in /var/www/drupal6/sites/all/modules/views_content_cache/views_content_cache.module at line 165.
Looking in the code, it seems that the db_query at line 165 is called even when $built_clause['#args'] is empty or in other way when $built_clause['#clause'] is equal to "(())". Putting the db_query at line 165 in a if condition seems to resolve the problem:
if ($built_clause['#clause']!='(())') {
$cache[$hash] = db_result(db_query("SELECT timestamp FROM {views_content_cache} WHERE {$built_clause['#clause']} ORDER BY timestamp DESC", $built_clause['#args']));
}
I don't think know if it's the best way to solve the problem.
Comments
Comment #1
steven jones commentedLooks like you may not have selected any cache segments to monitor in the settings for the cache plugin.
But, we should warn about this, and not generate errors.
Comment #2
andypanix commentedHi, great! A super fast reply! But... sorry, what do you mean for "selected any cache segments to monitor in the settings for the cache plugin"? I think I set all the options available. Thanks
Comment #3
steven jones commentedIn the Views UI, click the settings cog for the cache plugin, and below where it has options for the min/max lifetimes there should be some checkboxes for the different cache segments.
Comment #4
andypanix commentedNo, all settings are checked. I've also tried to disable all views blocks and views contents (Views attach) on the pages that generate the error but the error was still there, so perhaps the problem is related with something else. There are a lot of contrib modules active on my site so for me is not so easy to isolate the problem. Perhaps this list can help you:
* @font-your-face
* Administration menu
* Administration theme
* Advanced help
* Apache Solr Search Integration
* Automatic Nodetitles
* BackReference
* Change password
* Chaos tool suite
* Checkbox Validate
* Content Construction Kit (CCK)
* Content Profile
* Content Taxonomy
* Date
* Global Redirect
* Google Analytics
* Javascript Aggregator
* jQuery UI
* jQuery Update
* Legal
* LoginToboggan
* Modal Frame API
* Modal Frame Contrib Package
* Multi-column checkboxes radios
* Node Reference URL Widget
* Node reference views
* onBeforeUnload API
* Password toggle
* Pathauto
* PHPMailer
* Printer, e-mail and PDF versions
* Protect Critical Users
* Rules
* Skinr
* SunMailer Newsletter
* Taxonomy Menu
* Taxonomy Views Integrator
* Theme Settings API
* Token
* Transliteration
* Typogrify
* Vertical Tabs
* Views
* Views Arguments Extras
* Views attach
* Views Bonus Pack
* Views Bulk Operations (VBO)
* Views content cache
* Views Slideshow
* Wysiwyg
Comment #5
steven jones commentedSo somehow the query builder is returning nothing as you say, and we should indeed handle this better.
Comment #6
steven jones commentedFixed the SQL error issue in http://drupal.org/cvs?commit=440932.
Comment #7
andypanix commentedHi, the dev version seems to solve the problem. No more SQL errors. Thanks