I note there are frequent PHP5 errors, which are usually resolved by inserting

(array)

somewhere, often in foreach() statement. This case:

Invalid argument supplied for foreach() in C:\workspace\mysite\modules\cck\content.module on line 624
In this case

foreach ($array as $key1 => $value1) {

is fixed if you change it to

foreach ((array)$array as $key1 => $value1) {

I used to get a fair number of these, and I found that if I develop in PHP5 environment I have fewer issues w/ PHP version-related bugs popping up. That's just me.
Thanks

CommentFileSizeAuthor
#5 cck_php5_changes.patch2.54 KBdado
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dado’s picture

Here's some more

Warning: Invalid argument supplied for foreach() in C:\workspace\mysite\modules\cck\nodereference.module on line 89
Warning: Invalid argument supplied for foreach() in C:\workspace\mysite\modules\cck\content.module on line 625

in each case, add
(array)
to fix.

dado’s picture

and another

Warning: array_pop() [function.array-pop]: The argument should be an array in C:\workspace\mysite\modules\cck\nodereference.module on line 175

dado’s picture

Priority: Minor » Normal

The latter one I had to change this

$node_field['nid'] = array_pop($node_field['nids']);

to this

if (is_array($node_field['nid'])) $node_field['nid'] = array_pop($node_field['nids']);
dado’s picture

Oops disregard last post. Maybe change to something like this

if (is_array($node_field['nids'])) {
            $node_field['nid'] = array_pop($node_field['nids']);
          } else {
            $node_field['nid'] = $node_field['nids'];
          }
dado’s picture

FileSize
2.54 KB

in case you should want it, i attach a patch which encompasses the above changes

webchick’s picture

Status: Active » Needs review
JonBob’s picture

Status: Needs review » Fixed

Patched in a slightly different manner.

Anonymous’s picture

Status: Fixed » Closed (fixed)