Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Getting a fatal error when submitting comments with the current stable version using Akismet as the provider. This happens when you click save (with or without previewing):
Fatal error: Cannot use string offset as an array in /var/www/drupal7/sites/all/modules/antispam/antispam.module on line 1014
When previewing comments you get the following warning:
Warning: array_merge() [function.array-merge]: Argument #1 is not an array in antispam_comment_view() (line 1140 of /sites/all/modules/antispam/antispam.module).
Comment | File | Size | Author |
---|---|---|---|
#10 | antispam.module.patch | 2.12 KB | egouleau |
Comments
Comment #1
kabojnk CreditAttribution: kabojnk commentedSubscribing. I'm getting this, too. It only occurs when using the "Identify spambots by...".
Also, why do all of my unregistered commenters' names get replaced with "Anonymous" when this module is enabled?
This is the offending piece of code:
And here's a PDO error for good measure if you comment out the previous line as well:
Comment #2
lsolesen CreditAttribution: lsolesen commented+1
Comment #3
lsolesen CreditAttribution: lsolesen commentedThis makes the module unusable, so setting the priority to critical.
Comment #4
libre fan CreditAttribution: libre fan commentedRecap: The following errors make Antispam unusable since I upgraded from D6 to D7. I tried uninstalling Antispam, and dropping the spam tables, reinstalling, but to no avail. Here's a sample of the errors I get:
Notice: Undefined index: comment in antispam_comment_view() (line 1140 of ...sites/all/modules/antispam/antispam.module).
Warning: array_merge() [function.array-merge]: Argument #1 is not an array in antispam_comment_view() (line 1140 of ...sites/all/modules/antispam/antispam.module).
This is what I get as a logged in user if I want to add a comment and click on the "preview" button. Can't get past the error since there's no Ok button after this error.
If I set Preview as optional and click the save button instead I get this error:
Fatal error: Cannot use string offset as an array in…sites/all/modules/antispam/antispam.module on line 1014
I haven't found an alternative to Antispam, Captcha mayn't be enough.
Comment #5
Crossfeed CreditAttribution: Crossfeed commenteddirty workaround as mentioned above is to uncheck all 'Identify spambots by' options.
But even then the module 'forgets' the authors name and sets it to guest. Really unusuable in its current version
Comment #6
mgiffordI'm hoping this might fix this up however I just got a report about this problem and wasn't able to replicate it.
That's instead of line 1014:
I am finding that in general antispam has been working for me.
Comment #7
mgiffordUltimately I had to mostly comment this out. I'm really not sure why the object that's being returned is producing an error. I think it only affects forum comments, but still it's a problem. This was the best documentation I could find about this general php issue:
http://informationideas.com/news/2006/06/14/fatal-error-cannot-use-strin...
I temporarily fixed this bug (well by commenting out the section) in this patch here:
#1349574: Coder Cleanup, Link Fix & Fatal Error Fix
Comment #8
danithaca CreditAttribution: danithaca commentedI have the same problem too. Subscribe.
Comment #9
jamescl CreditAttribution: jamescl commentedWas also occurring with comments on node, patch in #7 solves for me.
Comment #10
egouleau CreditAttribution: egouleau commentedwell, in fact there are 2 errors in the function antispam_comment_presave($comment)...
Find out that the query conditions where bad when checking the antispam options
but also the debug_info['Content'] do not get the right value...
we don't want $comment->mail but $comment->body :)
that's solve the
and on line 1012
but when looking to the table comment in the db there is no "comment" field ...
there's missing another query join to get this function to work.
I changed the code like this on line 993 :
and on line 1012 :
solve the problem for me :)
Hope it helps
Comment #11
monbro CreditAttribution: monbro commented@egouleau your solution worked for me, thanks!
When i change or insert a new user, there was also a fatal error.
Solved (and working) by changing the line:
to
Comment #16
wxman CreditAttribution: wxman commentedI just found I had this going on too. The patch worked for me as well.
Comment #17
tim.plunkettThere was a similar fix over here: #1483796: AntiSpam fatal error when posting comments.
That has been committed. Please test and see if this issue was a duplicate.
Comment #18
lklimek CreditAttribution: lklimek commentedI got the "Fatal error: Cannot use string offset as an array in /var/www/drupal7/sites/all/modules/antispam/antispam.module on line 1014" error recently, but installing latest -dev version fixed my problem.
Comment #19
DamienMcKennaThis was fixed in #1483796: AntiSpam fatal error when posting comments..
Comment #20
manuscle CreditAttribution: manuscle commentedPatch worked for me too :)