Skip to content

[Cache] FilesystemCommonTrait - rename fails on windows #50326

@lekoala

Description

@lekoala

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)"} []

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy