[BUGFIX] Avoid fatal when flushed directory is a symlink
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Classes / Utility / GeneralUtility.php
index 50102cd..004ffc1 100644 (file)
@@ -2164,8 +2164,13 @@ class GeneralUtility
     {
         $result = false;
 
+        if (is_link($directory)) {
+            // Avoid attempting to rename the symlink see #87367
+            $directory = realpath($directory);
+        }
+
         if (is_dir($directory)) {
-            $temporaryDirectory = rtrim($directory, '/') . '.' . StringUtility::getUniqueId('remove') . '/';
+            $temporaryDirectory = rtrim($directory, '/') . '.' . StringUtility::getUniqueId('remove');
             if (rename($directory, $temporaryDirectory)) {
                 if ($flushOpcodeCache) {
                     self::makeInstance(OpcodeCacheService::class)->clearAllActive($directory);