[TASK] Have PackageManager only check for TYPO3 extensions 77/46377/2
authorBenni Mack <benni@typo3.org>
Fri, 29 Jan 2016 19:20:38 +0000 (20:20 +0100)
committerBenni Mack <benni@typo3.org>
Fri, 29 Jan 2016 20:11:17 +0000 (21:11 +0100)
Currently the PackageManager class checks for TYPO3 extensions
and for directories within typo3/sysext/ typo3/ext/ or typo3conf/ext/
that contain a composer.json but no ext_emconf.php.

However, as the additional check, which only checks for the
existance of composer.json was part of the legacy functionality
from the old Flow backport and is not used anymore.

Resolves: #73019
Releases: master
Change-Id: I494030d6ee133b4db35387e20b326f9215edfc4e
Reviewed-on: https://review.typo3.org/46377
Reviewed-by: Daniel Maier <dani-maier@gmx.de>
Tested-by: Daniel Maier <dani-maier@gmx.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
typo3/sysext/core/Classes/Package/PackageManager.php

index d0369db..3f874a3 100644 (file)
@@ -315,12 +315,7 @@ class PackageManager implements \TYPO3\CMS\Core\SingletonInterface
                 unset($this->packagesBasePaths[$key]);
             }
         }
-
-        $packagePaths = $this->scanLegacyExtensions();
-        foreach ($this->packagesBasePaths as $packagesBasePath) {
-            $packagePaths = $this->scanPackagesInPath($packagesBasePath, $packagePaths);
-        }
-
+        $packagePaths = $this->scanPackagePathsForExtensions();
         foreach ($packagePaths as $packagePath) {
             $packagesBasePath = $this->packagesBasePath;
             foreach ($this->packagesBasePaths as $basePath) {
@@ -360,16 +355,12 @@ class PackageManager implements \TYPO3\CMS\Core\SingletonInterface
     /**
      * Fetches all directories from sysext/global/local locations and checks if the extension contains an ext_emconf.php
      *
-     * @param array $collectedExtensionPaths
      * @return array
      */
-    protected function scanLegacyExtensions(&$collectedExtensionPaths = array())
+    protected function scanPackagePathsForExtensions()
     {
-        $legacyCmsPackageBasePathTypes = array('sysext', 'global', 'local');
+        $collectedExtensionPaths = [];
         foreach ($this->packagesBasePaths as $type => $packageBasePath) {
-            if (!in_array($type, $legacyCmsPackageBasePathTypes, true)) {
-                continue;
-            }
             /** @var $fileInfo \SplFileInfo */
             foreach (new \DirectoryIterator($packageBasePath) as $fileInfo) {
                 if (!$fileInfo->isDir()) {
@@ -393,25 +384,6 @@ class PackageManager implements \TYPO3\CMS\Core\SingletonInterface
     }
 
     /**
-     * Looks for composer.json in the given path and returns TRUE or FALSE if an ext_emconf.php exists
-     * or no composer.json is found.
-     *
-     * @param string $packagePath
-     * @return bool TRUE if a composer.json exists or FALSE if none exists
-     */
-    protected function hasComposerManifestFile($packagePath)
-    {
-        // If an ext_emconf.php file is found, we don't need to look further
-        if (file_exists($packagePath . 'ext_emconf.php')) {
-            return false;
-        }
-        if (file_exists($packagePath . 'composer.json')) {
-            return true;
-        }
-        return false;
-    }
-
-    /**
      * Requires and registers all packages which were defined in packageStatesConfiguration
      *
      * @param bool $registerOnlyNewPackages
@@ -887,33 +859,6 @@ class PackageManager implements \TYPO3\CMS\Core\SingletonInterface
     }
 
     /**
-     * Scans all sub directories of the specified directory and collects the package keys of packages it finds.
-     *
-     * The return of the array is to make this method usable in array_merge.
-     *
-     * @param string $startPath
-     * @param array $collectedPackagePaths
-     * @return array
-     */
-    protected function scanPackagesInPath($startPath, array $collectedPackagePaths)
-    {
-        foreach (new \DirectoryIterator($startPath) as $fileInfo) {
-            if (!$fileInfo->isDir()) {
-                continue;
-            }
-            $filename = $fileInfo->getFilename();
-            if ($filename[0] !== '.') {
-                $currentPath = $fileInfo->getPathName();
-                $currentPath = PathUtility::sanitizeTrailingSeparator($currentPath);
-                if ($this->hasComposerManifestFile($currentPath)) {
-                    $collectedPackagePaths[$currentPath] = $currentPath;
-                }
-            }
-        }
-        return $collectedPackagePaths;
-    }
-
-    /**
      * Returns contents of Composer manifest as a stdObject
      *
      * @param string $manifestPath