In the very latest dev (dec 18) an error has cropped up. This wasn't in the penultimate dev release from dec 16 (?)

warning: Invalid argument supplied for foreach() in ......../modules/imagefield/imagefield.module on line 252.
warning: array_values() [function.array-values]: The argument should be an array in ......../modules/imagefield/imagefield.module on line 260.

Comments

dopry’s picture

Status: Active » Postponed (maintainer needs more info)

And what were you doing when you saw this error? It's wonderful to know you saw the error, but if I don't have directions to reproduce it I can't fix it.

bobdalob’s picture

sorry::

node creation. the error arose whether uploading an image or previewing the node (without using the upload button) and the error was shown in the image field form on the node create page.

Filename does not appear to matter and the node can go on to be published with no apparent problem.

I cannot pinpoint any trigger factors or sequences - I've tested filenames, I've tried upload/preview/replace etc. - there's no apparent consistency or pattern I can identify. It happens most times but not every time.

There was no such issue with the earlier dev releases and everything else is the same (config of image field module and rest of site is the same).

dopry’s picture

How is the imagefield configured?

bobdalob’s picture

single image field, max. 480x480, image path [user-raw], default file extensions, custom title text enabled, not required, no multiple values.

cck is 1.6-1, public download, jquery is 1.2.1, drupal 5.5, php 5.2.3, mysql 5.0.24a. the module is unpatched and again nothing was changed between a previous dev version being error-free and this version. I didn't keep a copy of the previous version however I have now reverted to 2.0-rc1 and the error does not occur.

** edited **
if I go back to the dev release the error occurs again.
wish I could somehow be more helpful. I cannot seem to find a copy of the penultimate release

jpetso’s picture

Status: Postponed (maintainer needs more info) » Active

status.

bobdalob’s picture

Just to add a couple more observations, same release:

No image = "missing image"
Even if image field is empty, the published node tries to show the image field:
...../files/imagecache/imageview" alt="" title="" />....

whereas a node with an image, the img src is:
...../files/imagecache/imageview/files/dummy/testpic.jpg" alt="testpic.jpg" title="Test pic" />...

imageview is the imagecache preset, dummy is the [user-raw] token

No image, no php error
If no image is attached to a node, the php error does not occur (on preview or submit, it will occur if "upload" is hit with an empty field).

vm’s picture

I can confirm this.

version 1.2 RC1 doesn't have this error
version 2.0 RC1 doesn't have this error

version 2.0-dev does.

The image itself still shows though even though the error is produced.

jaydub’s picture

I can also confirm this bug. If you examine the RC1 source you can see that the code block that is referenced in the error above was wrapped in a test condition in RC1 but not in the dev version.

I added the test condition from RC1 and the error goes away.

function imagefield_field($op, $node, $field, &$items, $teaser, $page) {
  $fieldname = $field['field_name'];
  switch ($op) {
    // called after content.module loads default data.
    case 'load':
      if (count($items)) {
        foreach ($items as $delta => $item) {
          if (empty($item)) {
            unset($items[$delta]);
          }
          elseif (!empty($item['fid'])) {
            $items[$delta] += _imagefield_file_load($item['fid']);
          }
        }
        $items = array_values($items); // compact deltas
      }
      break;
vm’s picture

confirmed that using the code above fixes the error message but introduces another bug.

After the image is uploaded and submitted.
edit the node, the image already attached cannot be edited the way it's supposed to be edited.

bobdalob’s picture

I can also confirm this fix along with minor bug (saw this yesterday but initially I [wrongly] attributed this elsewhere)

In node edit, previously published images are not shown.

Images will be re-appear in the image field form if you hit the upload button whether you are uploading further images or just leaving the browse box empty. Even if you make no changes the original images will re-appear in node view when re-submitted.

vm’s picture

Version: 5.x-2.x-dev » 5.x-2.0-rc2
Status: Active » Fixed

the release of 2.0 RC2 fixes the error that was originally seen.

will file a seperate report for the fact that when after an image is uploaded, when you enter the edit screen of a node there is no delete checkbox.

dopry’s picture

Version: 5.x-2.0-rc2 » 5.x-2.x-dev
Status: Fixed » Active

This should be fixed in RC2.

dopry’s picture

Version: 5.x-2.x-dev » 5.x-2.0-rc2
Status: Active » Fixed

wow people close my issues quicker than I can...

vm’s picture

my apologies. I am watching this module closely because I'd love to implement it on a site I am working on to promote some music with an image. Didn't mean to close it quicker than you could ; )

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.