Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment | File | Size | Author |
---|---|---|---|
file-21914.patch | 570 bytes | CarlHinton | |
Comments
Comment #1
CarlHinton CreditAttribution: CarlHinton commentedComment #2
gmclelland CreditAttribution: gmclelland commentedSimilar issue
Comment #3
dooug CreditAttribution: dooug at Promet Source commentedThis is similar to #1333390: file_prepare_directory() / is_writable() on Linux don't support ACLs which points to this issue which has lots of work that should solve the problem: #944582: ./sites/default/files directory permission check is incorrect during install AND status report (affects Docker on Windows)
So I'm closing this in favor of the ongoing work on: #944582: ./sites/default/files directory permission check is incorrect during install AND status report (affects Docker on Windows)
Comment #4
cleverhoods CreditAttribution: cleverhoods as a volunteer commentedAnother solution (for Drupal 7)
You can solve this issue by defining your own Stream Wrapper.
Via: Writing Stream Wrappers