When using the Filesystem remove method on a directory, doRemove always gets called with $isRecursive set to "false", but the entire directory is deleted anyway, regardless of what is passed in.
The issue is not that the entire directory is deleted, that much makes sense, but that the parameter seemingly does nothing.
tiller1010 commentedSep 22, 2022
Symfony version(s) affected
v5.4.12 - 6.x
Description
When using the Filesystem
remove
method on a directory,doRemove
always gets called with$isRecursive
set to "false", but the entire directory is deleted anyway, regardless of what is passed in.The issue is not that the entire directory is deleted, that much makes sense, but that the parameter seemingly does nothing.
In fact, when "false" is passed in for
$isRecursive
, the directory is temporarily renamed, and it cannot be deleted without an error.$lastError
gives "Text file busy" after the rename: https://github.com/symfony/symfony/blob/6.2/src/Symfony/Component/Filesystem/Filesystem.php#L191This error does not show if I manually set the argument to "true".
How to reproduce
Change the second argument to true https://github.com/symfony/symfony/blob/6.2/src/Symfony/Component/Filesystem/Filesystem.php#L150
Delete some directory with files
Possible Solution
Remove the parameter and the code that listens to it https://github.com/symfony/symfony/blob/6.2/src/Symfony/Component/Filesystem/Filesystem.php#L163
Additional Context
The text was updated successfully, but these errors were encountered: