Download & Extend

Trying to get property of non-object in filefield_file_download()

Project:FileField
Version:6.x-3.8
Component:Code
Category:bug report
Priority:minor
Assigned:Unassigned
Status:closed (fixed)
Issue tags:PHP 5.3

Issue Summary

With Private Files enabled in OS X with PHP 5.3 and Content, Filefield, and Imagefield enabled in Pressflow Drupal 6....

After saving a node with a new image attached:
Notice: Trying to get property of non-object in filefield_file_download() (line ... of ... filefield.module)

In my debugger $file is showing up as a bool with a value of 0 at line 137 of HEAD. I guess that 0 means NULL? Because changing

<?php
// If the file is not found in the database, we're not responsible for it.
if (!isset($file)) {
  return;
}
?>

to

<?php
// If the file is not found in the database, we're not responsible for it.
if (empty($file)) {
  return;
}
?>

resolves the issue.

OK?

Comments

#1

Patch.

AttachmentSize
filefield-996338.patch 549 bytes

#2

Status:active» needs review

#3

Status:needs review» reviewed & tested by the community

Hm, interesting. I wonder if isset() has ever really worked here. Clearly empty() is going to be a more robust check here. You running into this problem is enough that I think this change should be made regardless of if it works in some situations.

#4

Status:reviewed & tested by the community» fixed

I've committed this patch. Thanks again.

#5

Status:fixed» closed (fixed)

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

nobody click here