When you delete a comment, you get an error in the form:
Fatal error: Cannot use object of type stdClass as array in /usr/local/www/americaninventorspot/sites/all/modules/advcache/advcache.module on line 76
You need to move the cache_clear_all() call and change the second arg to the call.
I'm not really familiar with how to submit changes, but here's what the code should look like starting at line 71 of advcache.module.
function advcache_comment($a1, $op) {
switch ($op) {
case 'delete':
case 'update':
case 'insert':
if ($op == 'delete') {
$nid = $a1->nid;
}
else {
$nid = $a1['nid'];
}
cache_clear_all('nid-'. $nid, 'cache_comment', TRUE);
$node = node_load($nid);
if ($node->type == 'forum') {
cache_clear_all('*', 'cache_forum', TRUE);
}
break;
}
}
Here's the diff:
--- /root/advcache/advcache.module Thu May 31 10:19:38 2007
+++ advcache.module Wed Jun 13 20:27:24 2007
@@ -73,14 +73,14 @@
case 'delete':
case 'update':
case 'insert':
- cache_clear_all('nid-'. $a1['nid'], 'cache_comment', TRUE);
-
if ($op == 'delete') {
$nid = $a1->nid;
}
else {
$nid = $a1['nid'];
}
+
+ cache_clear_all('nid-'. $nid, 'cache_comment', TRUE);
$node = node_load($nid);
if ($node->type == 'forum') {
Comments
Comment #1
ray007 commentedsubscribing
Comment #2
robertdouglass commentedThank you, fixed.
Comment #3
dkruglyak commentedCache should also be reset when comment is published / unpublished, a common occurence if moderation or spam filters are used. Publish / unpublish operations also pass object instead of array and the best way to fix the logic is with casting.
Attached is the patch against the development version.
Comment #4
robertdouglass commentedoh yes, good catch. Thanks.
Comment #5
(not verified) commented