Closed (fixed)
Project:
Link
Version:
6.x-2.7
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Reporter:
Anonymous (not verified)
Created:
24 Sep 2009 at 19:15 UTC
Updated:
11 Jul 2015 at 02:47 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
dropcube commentedI have committed a fix for this issue. Could you please test and confirm.
Comment #2
Anonymous (not verified) commentednow it works
Comment #3
andrewlevine commentedgreat
Comment #4
netsensei commentedDidn't work for me. Ik got the same error on line 367.
Had link 2.6 installed, replaced it with link 2.x-dev version. I checked update.php but no updates were required. Went to a Views page with a list of nodes which use link fields: got the operand error.
Comment #5
dropcube commentednetsensei: could you please export your view and content type to see if I can reproduce the bug ?
Comment #6
srobert72 commentedI have also same error :
Fatal error: Unsupported operand types in /home/drupal/drupal/sites/all/modules/link/link.module on line 367
Here is my Views code :
Comment #7
dropcube commentedCan you confirm that this happens with the current dev version ? I can not reproduce the bug. Could you please try with the most recent dev version and confirm. Thanks.
Comment #8
srobert72 commentedYes it happens with 6.x-2.x-dev version
Comment #9
arcaicI get the same error in line 367 as well.
I just installed the dev version (no version ever installed before) and created a new content type (test) with just the link field.
Required field, no title, nofollow, open in new window.
Created a node of type test - Entered the url and previewed - Error displayed.
If I save it seems ok, displays fine if I view or edit the node. If I edit and preview again - It errors.
Unsupported operand types in .../sites/all/modules/link/link.module on line 367
Comment #10
arcaicOk... I know very little PHP but it seems to me that on line 360 if item['attributes'] is not an array then you unserialize it and assume that it will be array after that. I took a guess that maybe that is not the case and stuck the following in
if (!is_array($item['attributes'])) {
$item['attributes'] = array();
}
So Line 359 onwards becomes..
if (!is_array($item['attributes'])) {
$item['attributes'] = unserialize($item['attributes']);
if (!is_array($item['attributes'])) {
$item['attributes'] = array();
}
}
I no longer get an error when previewing and things 'seem' ok.
No idea if that is the right fix for the right problem but maybe it gives a clue. item['attributes'] is not an array when you do the +=
Andy
Comment #11
Tom Freudenberg commentedAndy, I agree but I think its not the problem of "unserialize", in my opinion it should be tested that $item['attributes'] does exist.
So I patched to (near by line 359)
Comment #12
dropcube commentedI had committed a fix for this. Please test.
Thank you guys.
Comment #13
benstallings commentedI'm now getting this error with brand new version 6.x-2.7. I see that the changes discussed above have already been made in this version. I'm getting the error on line 371, which is
Comment #14
benstallings commentedThe problem seems to be that if $item['attributes'] is set to an empty string, unserializing it doesn't make it an array. :-)
I changed line 364 to
and the error went away.
Comment #15
cronix commentedSubscribing #14 seems to work for me
Comment #16
lennart commentedI can confirm the bug. And the fix works.
Comment #17
GatorBat commentedJust wanted to confirm I too have encountered the bug mentioned in #13: PHP Fatal error: Unsupported operand types in sites\all\modules\link\link.module on line 371
The fix suggested in #14 on line 364 has worked for me as well.
Comment #18
jackread commentedthanks BenStallings :-)
Comment #19
jcfiala commentedWhups. I'll take a look at that when I get home, plug it in, and do a little testing. Sounds like 6.x-2.8 might be coming out soon, sorry folks.
Comment #20
extect commentedThe following patch solves the issue for me, but I took a different approach than in #14.
I think the error occurs, because
+=should only be used for arithemtic operations and not for arrays.So I changed
$item['attributes'] += $field['attributes'];to
$item['attributes'][] = $field['attributes'];and
$field['attributes'] += _link_default_attributes();to
$field['attributes'][] = _link_default_attributes();Comment #21
alexkb commentedBenStallings (#14) patch worked for us, cheers!
Comment #22
syoung731 commentedI did as #20 but I ended up with
warning: preg_match() expects parameter 2 to be string, array given in /home/content/t/h/e/thesignforum/html/includes/bootstrap.inc on line 777.
Comment #23
syoung731 commentedDid as 14 suggested and the error went away thanks
Comment #24
harpa413 commentedimplemented fix from #14 -- line 371 -- and the problem appeared to resolve.
however, i then went in to edit one of the affected nodes containing a (single) link, at which point i get (multiple instances of) this warning:
warning: unserialize() expects parameter 1 to be string, array given in /Users/me/Sites/client/sites/all/modules/link/link.module on line 371.
it doesn't stop me from updating the node, but it does suggest this fix isn't sufficient.
i'm using a link with a static title and rel=nofollow.
Comment #25
jcfiala commentedSo, I threw together a quick and dirty test here, and I'm not having this error with a standard link field... unless I'm displaying that field in a view, as a field. Does this duplicate what other people are seeing?
Comment #26
jcfiala commentedOkay folks - I've just speed-released a 6.x-2.8 version of Link that implements BenStallings' patch in #14.
Thanks, and sorry for the code breaking there.
This is why I need to spend some time making some automated tests on link.
Comment #27
dropcube commentedI tested the current version with the fix from #14 applied, and is working Ok for me, displaying the full node, and displaying the field in a view.
Comment #28
dropcube commentedComment #29
cafuego commented+= is a valid arrays operator in PHP. The problem was that one of the parameters in question was not an array.
Comment #30
jcfiala commentedThis does not need review.
This is now fixed in link-6.x-2.8 - download it and see.
Comment #31
harpa413 commentednew 2.8 update fixes issue for me.
thank you so much!!
Comment #32
bkenro commented2.8 works fine also for me.
Thank you very much for the quick fix!
Comment #33
GatorBat commentedConfirming that 2.8 works for me as well (my original post was #17), thanks much for the quick fix :)
Comment #34
rainbreaw commented2.8 worked for me, as well. Thank you for being so quick!
I'm adding this comment because the problem didn't appear for me until I enabled workflow on a content type. My initial searches included the words "drupal" and "workflow" an so this thread did not come up. If anyone else experiences the same thing, hopefully this thread will come up for them now.
Comment #35
betz commentedI ipdated link module to 2.8 but i still got a error when bulk updating url aliases.
This is the error:
Fatal error: Unsupported operand types in /home/drupalcamp/default_www/sites/all/modules/link/link.module on line 368Comment #36
jcfiala commentedThis ticket has gotten a bit long, and has been applied to a number of versions, so I'm splitting it off into #626932: Unsupported Operand Types - Bulk URL Aliases to help keep things organized. betz, if you could respond there with more details? Thank you.