In imce.inc, the filefield_source_imce_value() function contains a hardcoded '/' instead of base_path() for $uri on line 135:
$uri = preg_replace('/^' . preg_quote('/' . $file_directory_prefix . '/', '/') . '/', $scheme . '://', $item['filefield_imce']['file_path']);

This should be:
$uri = preg_replace('/^' . preg_quote(base_path() . $file_directory_prefix . '/', '/') . '/', $scheme . '://', $item['filefield_imce']['file_path']);

As a result, when Drupal is installed in a subdirectory (i.e. '/drupal'), $uri ends up with a value of '/drupal/sites/default/files/example.png' instead of 'public://example.png' as expected, causing the fid lookup on line 138 to return no matching records and triggering an error.

Fix is attached.

CommentFileSizeAuthor
filefield_sources-imce-base_path.patch768 bytesmuriqui

Comments

quicksketch’s picture

#436182-46: IMCE lists unusable files (The selected file could not be used because the file does not exist in the database) also notes an additional problem with private files. It might be good to include that mentioned fix in here as well.

quicksketch’s picture

Status: Needs review » Fixed

Ah well, for now let's include this one and worry about private files later. Committed to 7.x-1.x branch.

Status: Fixed » Closed (fixed)

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