Download & Extend

Wrong uses of array instead of object in abuse_comment()

Project:abuse
Version:5.x-1.0-beta
Component:Code
Category:bug report
Priority:normal
Assigned:claudiu.cristea
Status:reviewed & tested by the community

Issue Summary

There is a PHP error in abuse_coment() function that leads to a PHP fatal error. The $comment variable is used as an array while it is an stdClass object.

The attached patch fix this.

AttachmentSize
abuse.module.patch596 bytes

Comments

#1

Hi Claudiu, I got this error too. However I think the root of the problem is a missing break statement. Per the api, hook_comment first parameter is an array when the op=update. Attached is a proposed patch. Feedback appreciated.

AttachmentSize
abuse_objasarray.patch 563 bytes

#2

Status:needs review» needs work

I have the patch from #1 applied and still get

Fatal error: Cannot use object of type stdClass as array in /mnt/target03/357371/www.momsteam.com/web/content/sites/all/modules/abuse/abuse.module on line 369

#3

Claudiu's original patch seems to solve this.

#4

Status:needs work» reviewed & tested by the community

I suspect that both patches are needed.

#5

Hi Nancy,
Its great to get immediate feedback!
The received the error (warning) when I deleted a comment. Once I added a break statement the warning went away, and this is rather obvious from the code.
I tried to update a comment to see whether I can reproduce the error on update comment operation, without applying Claudiu's patch, and I didn't get any error or warning. I verified that indeed the abuse_comment function was called by printing to the screen. So bottom line, I can't reconstruct the problem you are having. I'm reluctant to apply Claudiu's patch without further understanding reasons/scenarios.
Best,
Bluetegu

#6

Claudiu's patch is pretty obvious to me. It changes array references to object references. Once I applied it, my problem went away immediately.

nobody click here