schmittjoh/metadata — pull request #40 by flip111 (2013-11-18 08:49:36+00:00)
Title: Update FileCache.php added fallback option when rename fails on windows

Under, unfortunately unknown, circumstances rename() does not work properly under windows when the target file exists. See also this comment http://us2.php.net/manual/en/function.rename.php#60341

When testing and removing the @ in front of rename() the following occured:

PHP Warning: rename(C:\inetpub\symfony\app\cache\prod\jms_diextra\metadata\met666B.tmp,C:/inetpub/symfony/app/cache/prod/jms_diextra/metadata/.cache.php): Access is denied. (code: 5) in C:\inetpub\symfony\vendor\jms\metadata\src\Metadata\Cache\FileCache.php on line 98

This is a patch to fix the problem for the windows platform. Like the comment describes the function will no longer be atomic (rename vs unlink+copy). But it seems to be the best solution available.

Sometimes it happens, sometimes it doesn't, i'm afraid i can't pinpoint the exact cause without diving into PHP internals and C.

The problem was found investigating this issue https://github.com/schmittjoh/metadata/issues/39