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

[Cache] FilesystemCommonTrait - rename fails on windows #50326

Open
lekoala opened this issue May 15, 2023 · 2 comments
Open

[Cache] FilesystemCommonTrait - rename fails on windows #50326

lekoala opened this issue May 15, 2023 · 2 comments

Comments

@lekoala
Copy link

lekoala commented May 15, 2023

Symfony version(s) affected

4.x > 6.x

Description

The rename function can fail on windows for some php versions

https://github.com/symfony/cache/blob/1ce7ed8e7ca6948892b6a3a52bb60cf2b04f7c94/Traits/FilesystemCommonTrait.php#LL107C17-L107C17

This is a current php issue here
php/php-src#7910

For context, I've found the issue while working with SilverStripe cache adapter (it's using cache version 4, but since it's an issue with the rename function, I suspect it's going to be the same for 5.x and 6.x)
silverstripe/silverstripe-framework#10634

I've also found that it has been an issue in composer that needed platform specific fix here
composer/composer#10446

How to reproduce

here is a demo here showing the issue

https://github.com/johnstevenson/php-rename-bug/actions/runs/1669358275

Possible Solution

Don't use rename function

replace with (for all, or only for windows using platform check)

$didCopy = copy($oldName, $newName, $context);

if (!$didCopy) {
    return false;
}

@unlink($oldName, $context);

return true;

Additional Context

Example error log
...\silverstripe-cache\...\configcache\U\F\QAdjY48zDlbAQWHpYUrw): Access is denied (code: 5) at ...\vendor\symfony\cache\Traits\FilesystemCommonTrait.php:115)"} []

@j-schumann
Copy link

Same problem here, Symfony 6.3, PHP 8.2, Windows Server 2019

lekoala added a commit to lekoala/symfony that referenced this issue Jan 3, 2024
@lekoala
Copy link
Author

lekoala commented Jan 3, 2024

Example of how it could be solved
lekoala@dd204ad

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

3 participants