diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php index a883fcafa6..334ec1cc14 100644 --- a/src/Symfony/Component/Filesystem/Filesystem.php +++ b/src/Symfony/Component/Filesystem/Filesystem.php @@ -478,14 +478,14 @@ class Filesystem throw new IOException(sprintf('Failed to write file "%s".', $filename), 0, null, $filename); } - $this->rename($tmpFile, $filename, true); if (null !== $mode) { if (func_num_args() > 2) { @trigger_error('Support for modifying file permissions is deprecated since version 2.3.12 and will be removed in 3.0.', E_USER_DEPRECATED); } - $this->chmod($filename, $mode); + $this->chmod($tmpFile, $mode); } + $this->rename($tmpFile, $filename, true); } /**