I have a module that sends new comments to a Skype chat session when they are published, by implementing hook_comment($a1,$op) and performing this action when $op=='publish'. It worked great for users posting comments. But I just tried to "unpublish" and then "publish" a comment as an administrator, and when I did that, I got the following error:

Fatal error: Cannot use object of type stdClass as array in /www/<site>/drupal-6.6/sites/all/modules/comment_snoop/comment_snoop.module on line 62

That line looks like this: $data = array('date' => date("M j, Y H:i:s",$a1['timestamp']), 'author' => $a1['author'], 'comment' => $a1['comment'] );

When a comment is posted by a user (comment_save() in comment.module), the $a1 parameter comes in as an array. But, apparently, when the comment is published from the administrative console (comment_admin_overview_submit() in comment.admin.inc), that parameter is passed in as an object (from _comment_load()). It is my belief that the type of that parameter should be consistent, regardless of what calls the function. If not, that behavior should certainly be documented so it doesn't have to be discovered through trial-and-error. I suspect this may have come up as a result of this change #156475: "publish" hook trigger in comment.module for patch less comment_notify integration.

Is this actually an issue? If so, what is the best fix for it? I suppose in comment_save() one could call _comment_load() before calling comment_invoke_comment(), just to make sure the passed objects look the same?

Comments

dddave’s picture

Status: Active » Closed (fixed)

I am closing this under the premise that the issue is already fixed. If the problem still persists feel free to reopen and adjust the settings.

talonxander4’s picture

This would be so freaking awesome.... Keep iT UP ! Emblibrary