diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php index f2fc7d52a8407..6193e727b4b2d 100644 --- a/src/Symfony/Component/Filesystem/Filesystem.php +++ b/src/Symfony/Component/Filesystem/Filesystem.php @@ -148,6 +148,8 @@ public function rename($origin, $target) * @param string $originDir The origin directory path * @param string $targetDir The symbolic link name * @param Boolean $copyOnWindows Whether to copy files if on Windows + * + * @throws \RuntimeException When creation of symlink raises an error that should not be suppressed */ public function symlink($originDir, $targetDir, $copyOnWindows = false) { @@ -169,7 +171,15 @@ public function symlink($originDir, $targetDir, $copyOnWindows = false) } if (!$ok) { - symlink($originDir, $targetDir); + if (false === @symlink($originDir, $targetDir)) { + $report = error_get_last(); + if (is_array($report) && $report['type'] & error_reporting()) { + if (defined('PHP_WINDOWS_VERSION_MAJOR') && false !== strpos($report['message'], 'error code(1314)')) { + throw new \RuntimeException('Unable to create symlink due to error code 1314: \'A required privilege is not held by the client\'. Do you have the required Administrator-rights?'); + } + throw new \RuntimeException(sprintf("%s in %s line %s", $report['message'], $report['file'], $report['line'])); + } + } } }