I'm getting a php warning when uploading images using the imagefield single image per node method. The exact error is:

warning: Invalid argument supplied for foreach() in .../sites/all/modules/image_fupload/includes/images.previewlist.imagefield.inc on line 44. 

I have a taxonomy field with a vocabulary that does not allow "tags". So when the code hits that line of code:
foreach ($form_taxonomy['taxonomy']['tags'] as $key => $value) {

The tags attribute hasn't been set so it prints the warning.

Adding if (is_array($form_taxonomy['taxonomy']['tags'])) before the for loop fixes the issue.

    if (is_array($form_taxonomy['taxonomy']['tags'])) {
      foreach ($form_taxonomy['taxonomy']['tags'] as $key => $value) {
        // taxonomy tags
        if (!in_array($key, $fields_preview_list['taxonomy'])) {        
          unset($form_taxonomy['taxonomy']['tags'][$key]);
        }
      }
    }
CommentFileSizeAuthor
#1 imagefield_conditional_tags_535160.patch1.57 KBhadsie
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hadsie’s picture

Version: 6.x-3.x-dev » 6.x-3.0-rc2
Status: Active » Needs review
FileSize
1.57 KB

here's a patch for this one.

grandcat’s picture

Thank you for the patch file, I'll check this.

grandcat’s picture

Status: Needs review » Fixed

Committed to HEAD. Thanks.

Status: Fixed » Closed (fixed)

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

shiva7663’s picture

The patch failed for me: "can't find file to patch at input line 8"

grandcat’s picture

Then just use the dev branch.

shiva7663’s picture

All right, and may Ghu have mercy on my soul....