Search code examples
phpdrupaldrupal-7backend

Drupal 7 - file.inc - file_put_contents(temporary://fileXXXXXX): failed to open stream


Using Mac OS X Yosemite, Apache, PHP 5.5.14, MySQL 5.6.19, Drupal 7.32

Drupal failing to write due to bad file path. The bad file path is temporary://fileXXXXXX. I cannot understand why Drupal is failing to convert temporary:// to /tmp.

I have configured the temporary files directory via Drupal admin UI, and confirmed it's modification in the DB...

SELECT * FROM variable WHERE name LIKE '%temporary_path';
+---------------------+------------+
| name                | value      |
+---------------------+------------+
| file_temporary_path | s:4:"/tmp" |
+---------------------+------------+

...and cleared caches just in case; however, to no avail. I've also confirmed the permissions on /tmp just in case: drwxrwxrwt.

As well, when switching back to my master branch via git and using a fresh copy of my DB (SQL dump from production) - the issue persists.

The errors are formatted as follows...

/.../includes/file.inc:1941 file_put_contents(temporary://fileXXXXXX): failed to open stream: "DrupalTemporaryStreamWrapper::stream_open" call failed

The issue is isolated to my local environment and is not effecting any shared environments; however, is thwarting my work progress. Any suggestions are greatly appreciated. Thank you.


Solution

  • After a tedious wade through multiple logs, I found this message...

    File temporary://filewFxsrd could not be copied, because the destination directory public://css is not configured correctly.

    ...Knowing that my public file path was sites/my-site/files, I discovered that said directory did not exist, which lead me to this solution...

    cd sites/my-site; mkdir files; chmod a+rwx files
    

    ...this is my local environment and the files directory is listed in our .gitignore so I'm not concerned with it's security; although, it is unclear to me how the directory was removed to begin with.

    Thank you all for your suggestions.