system:FC5
PHP:5.1.2

error:"warning: array_merge_recursive() [function.array-merge-recursive]: Argument #2 is not an array in /var/www/html/web47/modules/node.module on line 1605"

error path:"?q=node/8888/edit"

CommentFileSizeAuthor
#12 node_66.patch813 byteschx

Comments

huyl’s picture

Status: Active » Needs review

fix node.module on line 1605 to:
"$form = array_merge_recursive($form, array(node_invoke($node, 'form')));"

killes@www.drop.org’s picture

Status: Needs review » Active

which node type does the node 8888 have?

huyl’s picture

It's a sample number.

huyl’s picture

This node type is "aggregator2-item",create by aggregator2 modules at 4.6.X.
yes,"page" and "blog" type no this warning.

asimmonds’s picture

Most 4.6 modules will not work with 4.7. Try using the CVS version of the aggregator2 module, which looks like it has been updated somewhat for 4.7. This module has not been branched for 4.7 yet, so it could be a little unstable.

gerhard killesreiter’s picture

please move this to aggregator2.module, it seems to be broken.

huyl’s picture

I agree,but it's better if can take node system more strong.

chx’s picture

Assigned: huyl » chx
Status: Active » Closed (won't fix)

I will relentless reject any proposals to make core more bloated to somewhat resist against broken modulen. Nah. Fix your code and leave core as it is.

adrinux’s picture

Version: 4.7.0-rc4 » 4.7.0

It's probably worth mentioning I also just got this error. This resulted from trying to edit old blog posts that were created using the blog module whilst the blog module was disabled. Once I enabled the old blog module the error disappeared, and I was able to edit the posts.

So this is basically a configuration error, not a bug as such, and should be easily corrected - as long as the module used to create the content is updated to the current Drupal version!

I'll be moving the problem content into 'story' nodes before disabling blog module again.

nsyll’s picture

the same problem when i try to make my oun node
at the end of hook_form i used

$output = drupal_get_form('myclient', $form);
return $output;

z.stolar’s picture

Version: 4.7.0 » 5.1
Priority: Normal » Critical
Status: Closed (won't fix) » Active

I just got this error with Drupal 5, and I see the code has not changed in Drupal 5.1 .
The problem occures when a module tries to add a content-type, but it does'nt use hook_form. The error is generated by the function array_merge_recursive, which expects to recieve a list of arrays.
If a certain module defines a content-type, but does not add anything special to its form, then node_invoke does not return anything, and the function breaks. The solution for this issue could be to return an empty array, by default:

<?php
function node_invoke(&$node, $hook, $a2 = NULL, $a3 = NULL, $a4 = NULL) {
  if (node_hook($node, $hook)) {
    $module = node_get_types('module', $node);
    if ($module == 'node') {
      $module = 'node_content'; // Avoid function name collisions.
    }
    $function = $module .'_'. $hook;
    return ($function($node, $a2, $a3, $a4));
  }
  # return an empty array, so the calling function won't break:
  else return array();
}
?>

This is classes critical, because while it might be not the ideal Drupal way, it's not unresonable for a module to add a content-type with no customed form fields (e.g. only a title and a body).

However, there seem to be another problem because, although the form has default values (has_title=>true for example), they don't render for module provided content-types, but that's a story for another issue.

chx’s picture

Status: Active » Reviewed & tested by the community
StatusFileSize
new813 bytes

Ladies and gentlemen, behold this issue! See the first reports which is "This is broken" without offering too much information (a reasonable assumption was that they returned strings) vs "this is how to reproduce and that's why it's broken". The first resulted in 'go away', the second? A patch. Similar constructs can be found in node_load.

BioALIEN’s picture

Status: Reviewed & tested by the community » Needs review

chx, while I agree with you - the patch does need some review first before its RTBC ;)

z.stolar’s picture

Can you be a bit more descriptive? Did you find any faults in it, ways to improve it?

pwolanin’s picture

Does it pass the E_ALL test?

Maybe the patch should be like:

-  $form = array_merge_recursive($form, node_invoke($node, 'form', $form_values));
+  $extra = node_invoke($node, 'form', $form_values);
+  if (is_array($extra)) {
+    $form = array_merge_recursive($form, $extra);
+  }
pwolanin’s picture

Priority: Critical » Normal

Since it's an uncommon case (other than the obvious case of disabling the module as mentioned above), i don't think it's critical.

pwolanin’s picture

Status: Needs review » Fixed

the patch in #12 seems to have already been applied to HEAD and 5.x, perhaps as part of another patch?

Anonymous’s picture

Status: Fixed » Closed (fixed)