I'm getting following errors when viewing userprofiles:
warning: array_merge() [function.array-merge]: Argument #2 is not an array in C:\Program Files\Apache Group\Apache2\htdocs\intranet\sites\default\modules\token\token.module on line 342.
warning: array_keys() [function.array-keys]: The first argument should be an array in C:\Program Files\Apache Group\Apache2\htdocs\intranet\sites\default\modules\token\token.module on line 345.
warning: array_values() [function.array-values]: The argument should be an array in C:\Program Files\Apache Group\Apache2\htdocs\intranet\sites\default\modules\token\token.module on line 346.
warning: Invalid argument supplied for foreach() in C:\Program Files\Apache Group\Apache2\htdocs\intranet\sites\default\modules\token\token.module on line 409.
warning: Invalid argument supplied for foreach() in C:\Program Files\Apache Group\Apache2\htdocs\intranet\sites\default\modules\pathauto\pathauto.inc on line 566.
I think it is connected to either Ldap_integration or Realname modules. Something Patch #4 from this issue http://drupal.org/node/886200 seems to fix the problem. I replaced array_merge($tokens['global']['default'], $tokens[$type][$id]); with merge($tokens['global']['default'], $tmp_tokens);. But I'm not sure if this is the right way to fix it.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | 1000894_token_array_merge_errors.patch | 500 bytes | hefox |
| #5 | token_array_merge_issue-1000894-5.patch | 968 bytes | btmash |
Comments
Comment #1
bakanyaka commentedForgot to add: I only getting this error when logged in as a simple user and viewing other users profile. Administrators can view any profiles without errors, also users get no errors while viewing own profiles.
Comment #2
gregglesGo to admin/reports/status and it will let you know which modules are causing this problem.
Comment #3
dave reidComment #4
staze commentedI also see this issue, but it only pops up about one in every 100 times I load a page, and goes back away.
admin/reports/status shows all green.
Comment #5
btmash commentedFrom what I have noticed, this seems to be happening with the token module. What I narrowed it down to occurring was:
1) The other 'non-global' tokens get created.
2) Token module checks if the global tokens exist (they don't at this time).
3) Token module creates global set of tokens.
However, it seems like the non-global tokens that were created get wiped out and so its trying to merge the global tokens against something that no longer exists. The patch I wrote basically moves the code so that the global tokens get created first and the other type after. It **seems** to fix the issue though it requires further review and testing.
Comment #6
dave reidI still think this is happening by some kind of edge case, otherwise this would have been reported way sooner. This is treating the symptom, but not the cause.
Comment #7
btmash commentedYou're right - I did some more testing and found that while the errors no longer show up on the page, some other strange issues are occurring. As a note, they involved
1) Pathauto
2) LDAP Integration (specifically the LDAP Data module)
which I'm trying to figure out on what the issue could be.
Comment #8
f2boot commentedHere is the explanation I have been able to build:
If you set LDAP Data Synchronization on "Every time user object loaded in Drupal"
(the problem does not seem to happen otherwise)
you enter this process (read "calls" between each line):
the problem is that token_get_values is called recursively (see first and last line of the process)
you run it once then it gets called
once for the user you want to see the profile of
and once for current user
note the last line of the process: $tokens array gets emptied before rebuilding it for the current user so $token data for the profile of the other user is erased => hence raising the error ...
i guess
$tokens['user']['current user id'] and $tokens['user']['other user profile id']
should be kept somehow through "Special-case global tokens" piece of code
and remerged after...
Comment #9
harvlad commentedI had these error messages after creating a new unverified ldap user. Changing ldap/data/syncronizing options to "When user logs in" fixed the issue. For us this was fine as it suited our requirements. It was previously set to "Every time user object loaded in Drupal"
Comment #10
hefox commentedAs comment 8 indicates, this is caused by someone resetting the tokens static cache during module_invoke_all('global', 'default').
There was a $temp_tokens variable that was always being set with the current tokens, so replaced $tokens[$type][$id] with it for the case that tokens got wiped and it is also working. The advantage of this patch vs the other is that if someone decides to do the same, ie wipe the internal cache, but during $token[$type][$id], it won't fall prone to a similar error.
However, I'd advised looking into *why* someone would be wiping the cache while generating tokens also.
Comment #11
hefox commentedChanging title to reflect that the issue can happen during other situations (I am getting it during custom module's database updates).
Comment #13
gregglesIf tokens change during the page request it makes sense to clear them.
For example, autonodetitle creates a temporary title of "ant" so when Pathauto gets tokens it needs to flush them in case the "ant" token title is set.
I'm not sure why this failed testing :(
I didn't review the code.
Comment #14
greggleshefox clarified the cause of this being a call to token_get_values from *within* a call to token_get_values. That is somewhat irregular. I can imagine it happening if you build the tokens on a node where a field is using a filter that includes token processing.
Comment #15
froboy#10: 1000894_token_array_merge_errors.patch queued for re-testing.
Comment #16
froboyI tested the patch and it seems to solve the problem for me. I do need to rebuild LDAP data on every user load so this will really help me out.
I can't tell why the testing failed either... resubmitted to see if it was a fluke.
Comment #18
reaneyk commentedsubscribe
Comment #19
dave reidThis is a duplicate of #886200: array_merge() errors in token_get_values.