API page: https://api.drupal.org/api/drupal/includes%21file.inc/function/file_prep...

If you have a valid file_uri_scheme (e.g. public) and the directory exists then an attempt is made to use is_writable('public://mydirectory/myfile') which will return FALSE as we are passing a URI instead of full filename to is_writable

Using drupal_realpath($directory) will not always work either as passing a full filename to drupal_realpath instead of a URI will return FALSE from drupal_realpath.

I would suggest this:

$writable = is_writable(drupal_realpath($directory) == FALSE ? $directory : drupal_realpath($directory));

Patch attached

Files: 
CommentFileSizeAuthor
file-21914.patch570 bytesCarlHinton
PASSED: [[SimpleTest]]: [MySQL] 40,254 pass(es).
[ View ]

Comments

Status:Active» Needs review