Closed (fixed)
Project:
Node import
Version:
master
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
6 Dec 2006 at 05:45 UTC
Updated:
15 Feb 2007 at 10:30 UTC
I'm using Drupal 4.7.3 running on PHP5.1 / MySQL 4.1 / IIS5.0
I installed a fresh Drupal 4.7.3 and then enable the node_import module. Everything seems to be working fine until I import the CSV file. An error was displayed which looked like:
warning: array_merge() [function.array-merge]: Argument #2 is not an array in c:\Inetpub\wwwroot\Stage\test\drupalnew\modules\node_import\node_import.module on line 609.
Is there anyway to solve this?
Comments
Comment #1
jamesJonas commentedSame problem. I have previously successfuly used this module using a similiar import cvs.
Drupal 4.7.4
Mysql 5.0.22
FC6
PHP 5.1.6
node_import.module - MAIN and 4.6 - Where is 4.7?
array_merge() [function.array-merge]: Argument #1 is not an array in /var/www/html/drupal/modules/node_import/node_import.module on line 609.
Thanks,
Comment #2
jamesJonas commentedThis is a php 5 issue. It seems the array_merge() function has stronger type casting. This means you have to be sure you are passing the variable as an array. I fixed this by explicitly casting the variable as an array by placing (array) in front of the variable. This is a hack as the variable should have been casted originally as an array. Here is the repaired code:
$errors = array_merge((array)$errors, (array)$function($node, $preview > 0));James
Comment #3
Robrecht Jacques commented$errorsis cast as array (see line 569), however the output of the function is not, so I've added a(array)in front of that.Fixed (node_import.module version 1.47) - reopen this issue if it is not.
Comment #4
jamesJonas commentedI assume that this means the correct version is:
$errors = array_merge((array)$errors, $function($node, $preview > 0));
Correct? james
Comment #5
Robrecht Jacques commentedHmm, no, I think
as the error reported was with argument #2. That was the way I fixed it.
But now I see that the error you, gogman, reported is about argument #1. Strange, as
$errors = array();appears a couple of lines above it.In any case it can't hurt to add it before both (and unfortunately I don't have a php5 handy to test).
Let me know where (array) must be added.
Comment #6
jamesJonas commentedThis is how I had implemented it in my code:
The larger question is if $errors or $function are suppossed to be arrays. Here is the php manual page with a warning.
http://www.php.net/array_merge
"The behavior of array_merge() was modified in PHP 5. Unlike PHP 4, array_merge() now only accepts parameters of type array. However, you can use typecasting to merge other types."
It was after reading this example that I decided to cast both variables. This was also why I asked an explicit question concerning Arg #1 versus Arg 2, since I was confused by your statement. My current recommendation is to cast both variables. I ran 70k node inserts using this modification. The more elegant solution is to set the variables as arrays earlier in the code, but since this is a common issue for several modules I felt a more direct appoach was called for.
Comment #7
Robrecht Jacques commentedFixed (added the cast to $errors too).
Comment #8
(not verified) commented