in file_field.inc the following code wrongly adds errors to watchdog

// Verify the file exists on the server.
    if (!empty($item['filepath']) && !file_exists($item['filepath'])) {
      watchdog('filefield', 'FileField was trying to display the file %file, but it does not exist.', array('%file' => $item['filepath']), WATCHDOG_WARNING);
    }

$item['filepath'] is the path relative to drupals "files" folder but the PHP function file_exists will look for $item['filepath'] as an absolute URL.

Comments

charlie-s’s picture

This is true and loads up the dblog with tons of errors that are not really errors.

quicksketch’s picture

$item['filepath'] is the path relative to drupals "files" folder but the PHP function file_exists will look for $item['filepath'] as an absolute URL.

Unfortunately $item['filepath'] is NOT relative to the files directory. It's always either A) relative to the Drupal root (if using public files) or B) absolute on the entire file system (if using private files). Drupal didn't start storing relative file paths based on the file directory until Drupal 7 through use of stream wrappers. The fact that Drupal stores the whole file path is exactly why so many people have problems when they try to move their file directory location.

charlie-s’s picture

I'm using public files and have not moved my files directory since I initially installed and configured Drupal. It is "files". In my case an example error would be "FileField was trying to display the file files/product-bulletin.pdf, but it does not exist." Of course, the file exists.

seanr’s picture

I'm seeing a lot of these too, and have not moved the site or anything. The location reported in the errors is almost always /poormanscron/run-cron-check.

Rhino-new’s picture

I'm getting this error at nearly every single page-load, including /admin/content

pwolanin’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)