From fafac386b72af30bb742d536742c4782d4e7909a Mon Sep 17 00:00:00 2001 From: Niels Keurentjes Date: Mon, 14 Mar 2016 12:27:41 +0100 Subject: [PATCH] Ensure stat cache is cleared for junctions when using outside modifications. --- src/Composer/Util/Filesystem.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Composer/Util/Filesystem.php b/src/Composer/Util/Filesystem.php index 80881df90..fd29d5218 100644 --- a/src/Composer/Util/Filesystem.php +++ b/src/Composer/Util/Filesystem.php @@ -613,6 +613,7 @@ class Filesystem if ($this->getProcess()->execute($cmd, $output) !== 0) { throw new IOException(sprintf('Failed to create junction to "%s" at "%s".', $target, $junction), 0, null, $target); } + clearstatcache(true, $junction); } /** @@ -637,7 +638,10 @@ class Filesystem * * #define _S_IFDIR 0x4000 * #define _S_IFREG 0x8000 + * + * Stat cache should be cleared before to avoid accidentally reading wrong information from previous installs. */ + clearstatcache(true, $junction); $stat = lstat($junction); return !($stat['mode'] & 0xC000); @@ -659,6 +663,7 @@ class Filesystem throw new IOException(sprintf('%s is not a junction and thus cannot be removed as one', $junction)); } $cmd = sprintf('rmdir /S /Q %s', ProcessExecutor::escape($junction)); + clearstatcache(true, $junction); return ($this->getProcess()->execute($cmd, $output) === 0); }