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);
Comments
Comment #1
doitDave commentedSubscribed. Created a patch to fix this. Also raised to major due to WSOD.
Comment #2
doitDave commentedComment #3
doitDave commented(Note for my issue queue: Contacted module maintainer due to maintenance status just today.)
Comment #4
doitDave commentedApplied the patch from #1 which will soon be available in the dev branch.