Skip to content

Commit

Permalink
Fallback to 'copy' and 'unlink' instead of 'rename'
Browse files Browse the repository at this point in the history
...to move a file without side effects.

This gist reproduces the problem:
https://gist.github.com/alcaeus/a367e895e6c55f7fb93870dcba46efa9

Same issue is fixed in a similary way in symfony core:
symfony/symfony#12533

resolves #6713
  • Loading branch information
Christian Bartels committed Jul 1, 2019
1 parent 3773c7b commit 69fa94c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/Doctrine/Common/Proxy/ProxyGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,11 @@ public function generateProxyClass(ClassMetadata $class, $fileName = false)

file_put_contents($tmpFileName, $proxyCode);
@chmod($tmpFileName, 0664);
rename($tmpFileName, $fileName);

if (true !== @rename($tmpFileName, $fileName)) {
copy($tmpFileName, $fileName);
unlink($tmpFileName);
}
}

/**
Expand Down

0 comments on commit 69fa94c

Please sign in to comment.