I was working with querypath and qpcache, and noticed that the created table "qpcache_xmlcache" was never getting filled.
I took a look at the code and noticed some of the dynamic sql functions were missing the final ->execute():
db_delete('qpcache_xmlcache')
->condition('hashkey', $hashkey)
+ ->execute();
db_insert('qpcache_xmlcache')
->fields(array(
'crckey' => $crckey,
'hashkey' => $hashkey,
'clearkey' => $key,
'body' => $body,
'expire' => $expire))
+ ->execute();
Also, the sql placeholders were being quoted incorrectly (http://drupal.org/node/310072):
$sql = 'SELECT clearkey, expire, body FROM {qpcache_xmlcache} WHERE crckey=\':crc\' AND hashkey=\':hash\' AND (expire = 0 OR expire > \':now\')';
should be
$sql = 'SELECT clearkey, expire, body FROM {qpcache_xmlcache} WHERE crckey=:crc AND hashkey=:hash AND (expire = 0 OR expire > :now)';
Finally, function QueryPath->set() $expire is expected to be a timestamp, but function qpcache_set() can pass it a string. QueryPath->set should check for string, and convert to stimestamp.
public static function set($key, $body, $expire = 0) {
list($crckey, $hashkey) = self::genMultiKey($key);
+ if (!is_numeric($expire)) {
+ $expire = strtotime($expire);
+ }
db_delete('qpcache_xmlcache')
->condition('hashkey', $hashkey)
->execute();
I'm new git, but I've attempted to make a patch file with "git diff -p --raw > qpcache.patch" attached below.
Comment | File | Size | Author |
---|---|---|---|
qpcache.patch | 2.01 KB | ytwater |
Comments
Comment #1
mbutcher CreditAttribution: mbutcher commentedI've reviewed the patch and it looks great. I will push it in as soon as I have the chance.