Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filesystem::doRemove() $isRecursive parameter has no purpose #47670

Closed
tiller1010 opened this issue Sep 22, 2022 · 2 comments
Closed

Filesystem::doRemove() $isRecursive parameter has no purpose #47670

tiller1010 opened this issue Sep 22, 2022 · 2 comments

Comments

@tiller1010
Copy link

tiller1010 commented Sep 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#L191
This error does not show if I manually set the argument to "true".

How to reproduce

$fs = new Filesystem();
$fs->remove('somedirectory');
  • Notice all files are deleted

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

stack-trace

@thomasdominic
Copy link

thomasdominic commented Oct 14, 2022

Hi,

Codebase is correct. $isRecursive is an internal parameter to know how we use this method

The parameter $isRecursive is not use to say : "Do it recursively", but it's use to say "I'm in a recursive call".

Cc @nicolas-grekas in afup :)

@stof
Copy link
Member

stof commented Oct 14, 2022

@thomasdominic is right here.

@stof stof closed this as completed Oct 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants