I have turned up the level of error reporting with an upgrade to Drupal 6.20 in preparation for the leap to Drupal 7. Our intent is to have as relatively few errors, warning and notices as we can with the upgrade to Druapl 6.20 and PHP 5.3 before the introduction of the Drupal 7 changes. As a result, we discovered a case of an undefined variable with this module. The error message came up as:

notice: Undefined index: fid in filefield_widget_value() (line 238 of /home/toomreco/drupal-6.20/sites/all/modules/filefield/filefield_widget.inc).

I believe the fix is to initialize the $file variable to NULL and then to wrap the line of code in an isset() like as follows:

    // Load file if the FID has changed so that it can be saved by CCK.
    $file = NULL;
    if (isset($item['fid'])) {
      $file = field_file_load($item['fid']);
    }

Perhaps this can be included in the development version so similar warnings do not appear for others?

Cheers!!

Files: 
CommentFileSizeAuthor
#1 filefield_widget_notice.patch508 bytesquicksketch

Comments

Title:Small nit about undefined $item['fid'] caseNotice: undefined $item['fid'] in filefield_widget.inc
Priority:Normal» Minor
Status:Active» Fixed
StatusFileSize
new508 bytes

Thanks, corrected with this patch.

Status:Fixed» Closed (fixed)

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

Your patch was a more elegant on line solution... Nicely done!