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.
Adding a term to a vocabulary gives the following error:
warning: array_merge_recursive() [function.array-merge-recursive]: recursion detected in /usr/www/users/knickerl/cleverzebra.com/includes/module.inc on line 473.
Then though this appeared to have no effect other than the error message, later on I got the following when trying to reorder a bunch of terms in the same vocabulary:
* user warning: Duplicate entry 'category/products/second-life/landscape-' for key 2 query: INSERT INTO url_alias (src, dst, language) VALUES ('taxonomy/term/4', 'category/products/second-life/landscape', '') in /usr/www/users/knickerl/cleverzebra.com/modules/path/path.module on line 110.
* user warning: Duplicate entry 'category/products/second-life/productivity-' for key 2 query: INSERT INTO url_alias (src, dst, language) VALUES ('taxonomy/term/3', 'category/products/second-life/productivity', '') in /usr/www/users/knickerl/cleverzebra.com/modules/path/path.module on line 110.
I don't know what to do, but thought I should report it somewhere. Hope this reaches someone who can work with those messages!
Comment | File | Size | Author |
---|---|---|---|
#7 | drupal7-n222074.patch | 1.71 KB | DamienMcKenna |
#7 | drupal7-n222074-with_comments.patch | 2.46 KB | DamienMcKenna |
#7 | drupal6-n222074-2.patch | 1.03 KB | DamienMcKenna |
#7 | drupal6-n222074-2-with_comments.patch | 1.39 KB | DamienMcKenna |
#5 | drupal6-n222074.patch | 1.01 KB | DamienMcKenna |
Comments
Comment #1
Gábor HojtsyFrom the line number, that recursion appears in module_invoke_all(), which collects data returned by modules.
Do you use any contributed modules? What core modules you have enabled?
Comment #2
Nick Wilson CreditAttribution: Nick Wilson commentedHi Gabor, pathauto is the only one that I think is enabled and could effect this. Which could make sense as the sql errors appear to be url_alias related?
Comment #3
Gábor HojtsyYes, definitely try disabling pathauto and then see what happens.
Comment #4
DamienMcKennaI've run across this in media_brightcove (#711586: Resolve PHP warning in media_brightcove_emfield_providers()) where the $result value was an empty array. It seems that if you pass empty arrays to array_merge_recursive() you get the "recursion detected" warning.
Comment #5
DamienMcKennaThe logic in module_invoke_all() does not correctly handle empty arrays. I've re-worked the logic slightly to more clearly define exactly when valid $result values are added to the $return array.
Discussion: It is debatable whether Drupal should have to worry about bugs in PHP that may be resolved in a future release, but the logic provided in this patch works around both the current issue and should not cause any issues.
FYI I've provided two patches, one with (somewhat redundant) comments and one without.
Comment #6
DamienMcKennaFYI the issue is in the current D6 release.
Comment #7
DamienMcKennaI found the same possible issue in Drupal 7 in both module_invoke_all() and module_hook_info().
Also, I had a slight typo in the patch, I hadn't closed one of the IF statements.
Comment #9
DamienMcKennaChanging the title to be more clear where the issue is.
The core problem is that if array_merge_recursive()'s second argument is an empty array it throws the following warning:
warning: array_merge_recursive() [function.array-merge-recursive]: recursion detected in /file.php on line x.
Lots of situations cause this to happen, e.g. the media_brightcove module I patched elsewhere.
Comment #10
chx CreditAttribution: chx commentedNote that I dont get a warning on array_merge_recursive(array(1), array()); . Tested with 5.2.11 and 5.3.1 too.
Comment #11
catchComment #12
David_Rothstein CreditAttribution: David_Rothstein commentedI'm guessing that http://api.drupal.org/api/function/update_invoke_all/7 has the same problem also. Sounds like this is a good case for a helper function...
Comment #13
chx CreditAttribution: chx commentedI can't see how this stops Drupal 7 from being released especially that the described PHP bug is not reproducible as I mentioned above. Also the code is a bit ugly, all you want is
if (!empty($result) && is_array($result))
instead of three lines of ifs. If something is !empty then it's isset too (isset is FALSE only for NULL for which empty is TRUE. Q.E.D.) but this only applies if this code is actually fixing something and if it does I need to know why / how. A test would be helpful which fails w/o the patch but passes w the patch.Comment #14
DamienMcKennaargh - #276423: Tests needed: module.inc
Comment #15
clemens.tolboomXRef to #211182-188: Updates run in unpredictable order where array_merge_recurse causes imho a real ugly bug through update_invoke_all