When deleting comments, I get the following error:

PHP Fatal error: Cannot use object of type stdClass as array in /..../all/modules/comment_revisions/comment_revisions.module on line 106

The error occurs in this piece of code in comment_revisions_comment():

db_query('DELETE FROM {comment_revisions} WHERE cid = %d', $a1['cid']);
 _comment_revisions_set_current_revision($a1['cid']);

The $a1 parameter for hook_comment can be an array or an object, depending on the operation:

$a1: Argument; meaning is dependent on the action being performed.

* For "validate", "update", and "insert": an array of form values submitted by the user.
* For all other operations, the comment the action is being performed on.

Possible fix: either use the object operator to access the cid property:

db_query('DELETE FROM {comment_revisions} WHERE cid = %d', $a1->cid);
 _comment_revisions_set_current_revision((array)$a1->cid);

Alternatively, check the type of $a1:

if (is_object($a1)) {
        $cid = $a1->cid;
      }else {
        $cid = $a1['cid'];
      }
      db_query('DELETE FROM {comment_revisions} WHERE cid = %d', $cid);
      _comment_revisions_set_current_revision($cid);
CommentFileSizeAuthor
#1 error_deleting_comments-1444990-2.patch777 bytesdoitDave

Comments

doitDave’s picture

Priority: Normal » Major
Status: Active » Patch (to be ported)
StatusFileSize
new777 bytes

Subscribed. Created a patch to fix this. Also raised to major due to WSOD.

doitDave’s picture

Status: Patch (to be ported) » Needs review
doitDave’s picture

(Note for my issue queue: Contacted module maintainer due to maintenance status just today.)

doitDave’s picture

Status: Needs review » Fixed

Applied the patch from #1 which will soon be available in the dev branch.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.