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!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Gábor Hojtsy’s picture

Status: Active » Postponed (maintainer needs more info)

From 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?

Nick Wilson’s picture

Hi 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?

Gábor Hojtsy’s picture

Yes, definitely try disabling pathauto and then see what happens.

DamienMcKenna’s picture

I'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.

DamienMcKenna’s picture

Status: Postponed (maintainer needs more info) » Needs review
FileSize
1.37 KB
1.01 KB

The 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.

DamienMcKenna’s picture

Version: 6.0 » 6.15

FYI the issue is in the current D6 release.

DamienMcKenna’s picture

I 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.

Status: Needs review » Needs work

The last submitted patch, drupal6-n222074-2-with_comments.patch, failed testing.

DamienMcKenna’s picture

Title: Array and SQL Errors when creating taxonomies » PHP bug/feature in array_merge_recursive() causes warning messages
Status: Needs work » Needs review

Changing 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.

chx’s picture

Note that I dont get a warning on array_merge_recursive(array(1), array()); . Tested with 5.2.11 and 5.3.1 too.

catch’s picture

Component: taxonomy.module » base system
David_Rothstein’s picture

I'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...

chx’s picture

Priority: Critical » Normal
Status: Needs review » Needs work

I 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.

DamienMcKenna’s picture

clemens.tolboom’s picture

XRef to #211182-188: Updates run in unpredictable order where array_merge_recurse causes imho a real ugly bug through update_invoke_all