On PHP5 I've got this
warning: array_merge() [function.array-merge]: Argument #2 is not an array in /modules/cck/imagefield.module on line 159.

So line 159
$values[$delta] = array_merge($node_field[$delta], _imagefield_file_load($file['fid']));

after reading http://drupal.org/node/36408#comment-53455 has to be modified in,

$values[$delta] = array_merge((array)$node_field[$delta], _imagefield_file_load((array)$file['fid']));

Comments

willdashwood’s picture

Shouldn't it be:

$values[$delta] = array_merge((array)$node_field[$delta], (array)_imagefield_file_load($file['fid']));

I was having the same problems until I made that change. Now all appears to be working fine.

RobRoy’s picture

Version: 6.x-3.x-dev » 4.7.x-1.x-dev
StatusFileSize
new3.99 KB

Just need the (array) on the second arg.

This patch also includes false/true capitalization.

drewish’s picture

StatusFileSize
new2.33 KB

Humm, I changed it around a bit so that the _imagefield_file_load() returns an array in either case.

FredCK’s picture

Component: Miscellaneous » Code
Priority: Normal » Critical

Maybe the following is a clearer replacement... just place:

          $fileData = _imagefield_file_load($file['fid']) ;
          if ( $fileData ) {
            $values[$delta]  = array_merge($node_field[$delta], $fileData );
            $node_field[$delta] = $values[$delta];
          }

Instead of:

          $values[$delta]  = array_merge($node_field[$delta], _imagefield_file_load($file['fid']));
          $node_field[$delta] = $values[$delta];

I'm setting it as "critical", as I'm having this issue on every single installation.

dopry’s picture

Status: Needs review » Fixed

Applied a modified version that added an array cast to node_field[delta] in the array_merge. committed to 4.7.

beauregard’s picture

I had the same problem and downloaded the newest version of imagefield.module. But the problem remained.
Then I tried to apply imagefield_array_fix.patch, the problem still remained.
Then I tried only to change 1 code of line as willdashwood suggested. And now it seems working.

m3avrck’s picture

Confirmed getting the same array_merge() errors.

Anonymous’s picture

Status: Fixed » Closed (fixed)