Description
Symfony version(s) affected
4.x > 6.x
Description
The rename function can fail on windows for some php versions
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)"} []