The temp directory is not prepared in Drupal\Core\File\FileSystem::saveData

Created on 27 November 2020, almost 4 years ago
Updated 14 February 2023, almost 2 years ago

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.

πŸ› Bug report
Status

Needs work

Version

9.5

Component
File systemΒ  β†’

Last updated about 11 hours ago

Created by

πŸ‡§πŸ‡ͺBelgium dieterholvoet Brussels

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024