diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php index 201d2f7457..3ff72d28fb 100644 --- a/src/Symfony/Component/Filesystem/Filesystem.php +++ b/src/Symfony/Component/Filesystem/Filesystem.php @@ -477,9 +477,9 @@ class Filesystem throw new IOException(sprintf('Failed to write file "%s".', $filename)); } - $this->rename($tmpFile, $filename, true); if (null !== $mode) { - $this->chmod($filename, $mode); + $this->chmod($tmpFile, $mode); } + $this->rename($tmpFile, $filename, true); } }