Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 292243

MTimeProtectedFastFileStorage crashes with concurrency.

$
0
0

Problem/Motivation

MTimeProtectedFastFileStorage is implemented in such a way that if the destination file has already been writen by another process it will crash.

This how it works:

[1] Dump data into a temporary file.
[2] Set the temporary file permissions to 0444
[3] Move (php's rename) the file to the final destination

On a concurrent scenario another process might have writen the destination file before [3] executes, and because the destination file has 0444 permissions, rename() will fail:

Uncaught PHP Exception Symfony\Component\Debug\Exception\ContextErrorException: "Warning: rename(sites/default/files/php/twig/.8ce54ded2f,sites/default/files/php/twig/424c69bc_views-view.html.twig_bebe34fa92/e2dd91915d.php): Access is denied. (code: 5)" at \core\lib\Drupal\Component\PhpStorage\MTimeProtectedFastFileStorage.php line 98

Proposed resolution

We need something better than php's rename... symfony has a Filesystem component, but I found it not suited for this particular task.

Implement a custom Filesystem component in Drupal to have better tools to deal with the file system.

Remaining tasks

User interface changes

None.

API changes

New API.

Data model changes

None.


Viewing all articles
Browse latest Browse all 292243

Trending Articles