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') {
CommentFileSizeAuthor
#3 advcache.module.patch576 bytesdkruglyak
advcache_module.diff512 bytesfurmans

Comments

ray007’s picture

subscribing

robertdouglass’s picture

Status: Active » Fixed

Thank you, fixed.

dkruglyak’s picture

Title: Deleting comment fails » Process all relevant hook_comment operations
Version: 5.x-1.3 » 5.x-1.x-dev
Status: Fixed » Reviewed & tested by the community
StatusFileSize
new576 bytes

Cache 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.

robertdouglass’s picture

Status: Reviewed & tested by the community » Fixed

oh yes, good catch. Thanks.

Anonymous’s picture

Status: Fixed » Closed (fixed)