[TASK] Upgrade and streamline typo3/phar-stream-wrapper to v3.1.1 73/60673/2
authorOliver Hader <oliver@typo3.org>
Sun, 5 May 2019 18:05:38 +0000 (20:05 +0200)
committerOliver Hader <oliver.hader@typo3.org>
Mon, 6 May 2019 20:39:09 +0000 (22:39 +0200)
Phar Stream Wrapper has been upgraded to version 3.1.1 in order to
solve performance and alias resolving issues. The interceptor has
been streamlined further.

composer require typo3/phar-stream-wrapper:^3.1.1

Resolves: #88277
Releases: master, 9.5, 8.7
Change-Id: Id6b08557ab507ef66e54d1f39992272fe4791405
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/60673
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Oliver Hader <oliver.hader@typo3.org>
Reviewed-by: Oliver Hader <oliver.hader@typo3.org>
composer.json
composer.lock
typo3/sysext/core/Classes/IO/PharStreamWrapperInterceptor.php
typo3/sysext/core/Tests/Functional/IO/PharStreamWrapperInterceptorTest.php
typo3/sysext/core/composer.json

index 91ad920..b699f72 100644 (file)
@@ -63,7 +63,7 @@
                "typo3/class-alias-loader": "^1.0",
                "typo3/cms-cli": "^2.0",
                "typo3/cms-composer-installers": "^2.0",
-               "typo3/phar-stream-wrapper": "^3.1.0",
+               "typo3/phar-stream-wrapper": "^3.1.1",
                "typo3fluid/fluid": "^2.6.0",
                "webmozart/assert": "^1.0"
        },
index a208541..a2e2d13 100644 (file)
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "c35f3fa1a21d51fe53bef3a32a429a5f",
+    "content-hash": "dd75c56b773d10022589ed34561b54ba",
     "packages": [
         {
             "name": "cogpowered/finediff",
         },
         {
             "name": "typo3/phar-stream-wrapper",
-            "version": "v3.1.0",
+            "version": "v3.1.1",
             "source": {
                 "type": "git",
                 "url": "https://github.com/TYPO3/phar-stream-wrapper.git",
-                "reference": "19edc4e0ca5174764e3c946431b8b00326304944"
+                "reference": "fff6f5e037882f816cd41a9f5ccd8d8f97bfdebf"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/TYPO3/phar-stream-wrapper/zipball/19edc4e0ca5174764e3c946431b8b00326304944",
-                "reference": "19edc4e0ca5174764e3c946431b8b00326304944",
+                "url": "https://api.github.com/repos/TYPO3/phar-stream-wrapper/zipball/fff6f5e037882f816cd41a9f5ccd8d8f97bfdebf",
+                "reference": "fff6f5e037882f816cd41a9f5ccd8d8f97bfdebf",
                 "shasum": ""
             },
             "require": {
                 "php": "^7.0"
             },
             "require-dev": {
+                "ext-xdebug": "*",
                 "phpunit/phpunit": "^6.5"
             },
             "type": "library",
                 "security",
                 "stream-wrapper"
             ],
-            "time": "2019-03-01T23:18:27+00:00"
+            "time": "2019-05-05T17:30:25+00:00"
         },
         {
             "name": "typo3fluid/fluid",
index a477199..3fd28de 100644 (file)
@@ -17,10 +17,11 @@ namespace TYPO3\CMS\Core\IO;
 
 use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Core\Utility\PathUtility;
+use TYPO3\PharStreamWrapper\Assertable;
 use TYPO3\PharStreamWrapper\Exception;
+use TYPO3\PharStreamWrapper\Manager;
 
-class PharStreamWrapperInterceptor implements \TYPO3\PharStreamWrapper\Assertable
+class PharStreamWrapperInterceptor implements Assertable
 {
     /**
      * Asserts the given path of a Phar file is located in a valid path
@@ -48,71 +49,12 @@ class PharStreamWrapperInterceptor implements \TYPO3\PharStreamWrapper\Assertabl
      */
     protected function isAllowed(string $path): bool
     {
-        $path = $this->determineBaseFile($path);
-        if (!GeneralUtility::isAbsPath($path)) {
-            $path = Environment::getPublicPath() . '/' . $path;
+        $invocation = Manager::instance()->resolve($path);
+        if ($invocation === null) {
+            return false;
         }
-
-        if (GeneralUtility::validPathStr($path)
-            && GeneralUtility::isFirstPartOfStr(
-                $path,
-                Environment::getExtensionsPath()
-            )
-        ) {
-            return true;
-        }
-
-        return false;
-    }
-
-    /**
-     * Normalizes a path, removes phar:// prefix, fixes Windows directory
-     * separators. Result is without trailing slash.
-     *
-     * @param string $path
-     * @return string
-     */
-    protected function normalizePath(string $path): string
-    {
-        return rtrim(
-            PathUtility::getCanonicalPath(
-                GeneralUtility::fixWindowsFilePath(
-                    $this->removePharPrefix($path)
-                )
-            ),
-            '/'
-        );
-    }
-
-    /**
-     * @param string $path
-     * @return string
-     */
-    protected function removePharPrefix(string $path): string
-    {
-        return preg_replace('#^phar://#i', '', $path);
-    }
-
-    /**
-     * Determines base file that can be accessed using the regular file system.
-     * For e.g. "phar:///home/user/bundle.phar/content.txt" that would result
-     * into "/home/user/bundle.phar".
-     *
-     * @param string $path
-     * @return string|null
-     */
-    protected function determineBaseFile(string $path)
-    {
-        $parts = explode('/', $this->normalizePath($path));
-
-        while (count($parts)) {
-            $currentPath = implode('/', $parts);
-            if (@file_exists($currentPath)) {
-                return $currentPath;
-            }
-            array_pop($parts);
-        }
-
-        return null;
+        $baseName = $invocation->getBaseName();
+        return GeneralUtility::validPathStr($baseName)
+            && GeneralUtility::isFirstPartOfStr($baseName, Environment::getExtensionsPath());
     }
 }
index 95984b4..339af0a 100644 (file)
@@ -21,17 +21,13 @@ use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
 class PharStreamWrapperInterceptorTest extends FunctionalTestCase
 {
     /**
+     * Explicitly copy extension directory & files instead of using symlink with $testExtensionsToLoad
+     *
      * @var array
      */
-    protected $testExtensionsToLoad = [
-        'typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_resources'
-    ];
-
-    /**
-     * @var array
-     */
-    protected $pathsToLinkInTestInstance = [
-        'typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_resources/bundle.phar' => 'fileadmin/bundle.phar'
+    protected $pathsToProvideInTestInstance = [
+        'typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_resources' => 'typo3conf/ext/test_resources',
+        'typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_resources/bundle.phar' => 'fileadmin/bundle.phar',
     ];
 
     protected function setUp()
index b013e83..49e59bc 100644 (file)
@@ -43,7 +43,7 @@
                "typo3/class-alias-loader": "^1.0",
                "typo3/cms-cli": "^2.0",
                "typo3/cms-composer-installers": "^2.0",
-               "typo3/phar-stream-wrapper": "^3.1.0",
+               "typo3/phar-stream-wrapper": "^3.1.1",
                "typo3fluid/fluid": "^2.6.0"
        },
        "require-dev": {