The warning message:
warning: array_merge_recursive() [function.array-merge-recursive]: recursion detected in includes/common.inc on line 1779.
The problem comes within function drupal_get_js(). I think it is "theme system".
Seems this problem has been arround for a while. It says that this appear almost randomly with modules.
I wrote a module that use hook_form_alter() to add more body fields. I installed Drupal to a URL like "http://foobar.com/html". And I use FCKeditor at the same time. This problem appears. I track all the way down to common.inc. With var_export(), I found that the warning comes when $data looks like this:
$data = array ( 0 => array ( 'basePath' => '/html/', ), 1 => array ( 'basePath' => '/html/', ), );
I think the "duplicate" means there are duplicated items in an array.
I tried to fix it with array_unique().
The original line 1779 looks like this:
$output .= '<script type="text/javascript">Drupal.extend({ settings: '. drupal_to_js(call_user_func_array('array_merge_recursive', $data)) ." });</script>\n";
I changed it into this:
$output .= '<script type="text/javascript">Drupal.extend({ settings: '. drupal_to_js(call_user_func_array('array_merge_recursive', array_unique($data))) ." });</script>\n";
The warning disappeared then.
I'm not sure if this really fix the problem, or is it just creating some new problems.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 372097_1.patch | 430 bytes | mbelos |
Comments
Comment #1
yookoala commentedNo. The solution sucks. FCKeditor disappeared then.
It seems that array_unique() sucks with multidimensional array and mess up the $data. I then tried Dorphalsig's version arrayUnique() and the warning is back! I played arround and nothing seems to make sense.
At last, after I reinstalled FCKeditor, things work mirically.
Still don't know what exactly cause the problem.
Comment #2
mbelos commentedOk I think I've found this issue. It looks like this occurs when PHP tries to recursively merge the arrays containing duplicate keys. The problem here is that FCKeditor (version 5.x-2.2-rc7) tries to add a JS setting for the base path, when one already exists... I've fixed this problem by removing like 940 in fckeditor.module, which reads:
drupal_add_js(array('basePath' => base_path()), 'setting');. For completeness, I've attached a patch file so that others can test as necessary.Comment #3
wwalc commentedAny hint on how to reproduce it? If it requires installing another module (like CCK) and following some special steps, then please give me some instructions.
Comment #4
fluxrider commentedCould this be a mysql/issue for versions like msq4 . I'm getting these now after upgrading from drupal 4.7 to 5 . I'm about to go to a mysql 5 so I'll find out I guess, but it just seems its a random error across a number of modules after upgrading . I've just begun getting them after upgrading fckeditor to the latest from rc7 where I wasn't getting it. In Another site it occurs with fck latest but only after I installed Location module and Gmap . Code? or Database? issue . It seems pretty widespread even out of drupal .
Comment #5
fluxrider commentedFWIW ,I started getting this error after upgrading to the latest stable release . I wasn't getting it in rc-7. I have applied this patch in the latest stable release for 5 and the error has disappeared and all seems good. Its been running with the line removed now for two days on a live site and no errors logged or problems with users .
Thanks heaps for this patch . I can sleep again.
Comment #6
MacMannn commentedI've recently downloaded and installed FCKeditor version 5.x.2.2 (Drupal version 5.18). After doing this I started to get the array_merge_recursive() warning. Specifically, this error showed up when I tried to edit textfields. (After installation of FCKeditor the WYSIWIG-tool handled this of course.) The error appeared only after submitting the changes to the field. The error isn't serious because it doesn't show when the page is reloaded (without further editing). It could be confusing for regular users however, and should therefor be fixed.
After removing the offending line of code from fckeditor.module (line #940) the warning did not manifest itself anymore. My problem was solved by removing this line aswell, but perhaps the removed line was necessary for some other kind of functionality which must now be broken. Time will tell, I guess; for now mbelos is my hero ;-) Thanks for the fix.
Comment #7
Jorrit commentedCan someone provide a simple guide to reproduce this problem?
Comment #8
Jorrit commentedClosed because of lack of response.