Problem/Motivation
In Drupal\Core\File\FileSystem::saveData,file_put_contents is called without calling prepareDirectory beforehand. In case the temporary directory does not yet exist, this results in the following error when trying to write a temp file:
Temporary file 'temporary://xxxx' could not be created
Steps to reproduce
1. Set $settings['file_temp_path'] to a folder that does not yet exist (eg. a subfolder of /tmp)
2. Somehow trigger Drupal\Core\File\FileSystem::saveData, eg. by clearing cache and visiting the front page with asset aggregation enabled
Proposed resolution
Call prepareDirectory before file_put_contents in Drupal\Core\File\FileSystem::saveData.
Remaining tasks
Write tests.
Issue fork drupal-3185180
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
dieterholvoet commentedComment #6
kunalkursija commentedI faced this issue today on a client website running Drupal 9.3, And had to manually create the tmp directory to overcome the error.
Comment #8
thirstysix commentedStill, am having the same issue
Comment #10
smustgrave commentedThis issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.
As a bug this will need a test case showing the issue.
Comment #13
liam morlandI have rebased this on 11.x. The merge request needs to be updated to target 11.x. @DieterHolvoet can you do this?
How would a test for this be done?
Comment #14
dieterholvoet commentedI changed the target branch.