AJAX calls are returning 500 errors, for example, when clicking "Customize this page" or "Change layout" on a Panels page.
This is from my server log:
PHP Fatal error: Unsupported operand types in sites/all/modules/contrib/ctools/plugins/content_types/token/token.inc on line 42,
This is the line in question:
$token += array('description' => '');
$token must be an array by the time this line executes, so I'm not sure what the error's about, but I worked around it like this:
//$token += array('description' => '');
$token['description'] = '';
This is a new problem; the Panels features had previously worked for me. I just upgraded Token to 7.x-1.1. Could that be a factor?
Comment | File | Size | Author |
---|---|---|---|
#14 | broken_token-1624460-14.patch | 722 bytes | realityloop |
#12 | broken_token-1624460-12.patch | 669 bytes | Deciphered |
Comments
Comment #1
merlinofchaos CreditAttribution: merlinofchaos commentedThat would indicate that somehow $token is not actually an array at that point.
Comment #2
rohnjeynolds CreditAttribution: rohnjeynolds commentedSorry for the delayed reply, and for leaving out an important detail: Line 41 is:
if (!empty($token['name'])) {
That's why I was assuming $token must be an array by the time it gets to line 42.
Comment #3
AaronBauman$token['name'] is not empty if $token is a string.
I ran into the same error after installing a D7 module that implemented hook_token_info, but did not return the correct format.
(In my case a module was upgraded from D6, where these values for hook_token_list were all strings.)
This debugging patch should let you know the culprit, which you can then fix or report appropriately
(be sure to enable devel module first):
Comment #4
quicksketchConfirmed, this was the problem for me too. Thanks @aaronbauman.
Comment #5
KartagisI get the same error when I try to add flexible panel layout at http://dev-7.ozses.net/tr/admin/structure/panels/layouts/add-flexible
Comment #6
KartagisThe issue persists.
Comment #7
KartagisComment #8
merlinofchaos CreditAttribution: merlinofchaos commentedThis is going to require someone who is getting this problem to help out with the debugging and figure out what $token *is* at that point, and maybe figure out what's breaking it.
Comment #9
KartagisHow can we debug? I'm guessing dpm won't work because I immediately get a 500. Maybe dd?
Comment #10
EclipseGc CreditAttribution: EclipseGc commentedYou can do what #3 illustrates. This will give the dpm value of $token before the error and set token to something that can get past the error as well.
If you are having this error, can you confirm/deny whether you are using flexible layouts?
Eclipse
Comment #11
EclipseGc CreditAttribution: EclipseGc commentedChanging the status on this. We need people who are getting this problem to actively help us debug it.
Eclipse
Comment #11.0
EclipseGc CreditAttribution: EclipseGc commentedRemoved information about my server and path from the issue
Comment #12
Deciphered CreditAttribution: Deciphered commentedSo I had this same issue, my cause was a not so great Contrib module that I won't get into.
The issue is that $token is a string where it should be an array, and CTools is doing a check (
!empty($token['name'])
) that logically should be failing, but isn't. To fix the issue, we simply need to add another conditional ofis_array($token)
.Patch attached.
Comment #13
realityloopWorks as advertised
Comment #14
realityloopprevious patch fails against 1.4, patch reroll against head
Comment #16
PhilYsorry, useless comment.
Comment #17
dooug CreditAttribution: dooug at Promet Source commentedThis seems like a work-around when the bug is actually in other custom or contrib modules that aren't returning the proper format from hook_token_info. According to previous comments:
#3
#12:
So it seems this patch shouldn't be necessary, but rather the issues should be filed against those other contrib modules, though they haven't been mentioned by name. Which modules cause this bug?
Comment #18
Deciphered CreditAttribution: Deciphered commentedMaybe so, but it's never a bad thing to ensure the data we are about to process is in the format it is expected to be, especially when it requires such a minor change.
However, I too dislike bandaid fixes, especially when the real issue never gets resolved, so maybe the solution is to implement this fix as well as some form of Watchdog notice to let any developers paying attention know that X module is at fault and to please report the issue.
Comment #19
couloir007 CreditAttribution: couloir007 commentedCould this be a php 5.3 issue? I'm getting other oddities that appear to be a 5.3 vs 5.4 and higher issue.
Sean
Comment #20
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedThe 5 year old patch to token.inc applied cleanly to the latest ctools 7.x-1.x-dev, but based on the previous comments this issue may need to be closed or postponed.