Wrong uses of array instead of object in abuse_comment()

claudiu.cristea - December 15, 2008 - 18:05
Project:abuse
Version:5.x-1.0-beta
Component:Code
Category:bug report
Priority:normal
Assigned:claudiu.cristea
Status:reviewed & tested by the community
Description

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

#1

bluetegu - April 2, 2009 - 14:52

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

NancyDru - April 2, 2009 - 16:35
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

NancyDru - April 2, 2009 - 16:40

Claudiu's original patch seems to solve this.

#4

NancyDru - April 2, 2009 - 16:41
Status:needs work» reviewed & tested by the community

I suspect that both patches are needed.

#5

bluetegu - April 2, 2009 - 17:55

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

NancyDru - April 2, 2009 - 22:44

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

 
 

Drupal is a registered trademark of Dries Buytaert.