[BUGFIX] Only scan package base paths if subdirectories exist 67/55567/3
authorMichael Oehlhof <typo3@oehlhof.de>
Sun, 10 Dec 2017 21:58:46 +0000 (22:58 +0100)
committerAndreas Fernandez <a.fernandez@scripting-base.de>
Mon, 5 Feb 2018 21:41:54 +0000 (22:41 +0100)
Include possible package base paths only if subdirectories are available.
Otherwise no extension can be found in the base path anyway.

Resolves: #83070
Releases: master, 8.7
Change-Id: I503623c607554a60bd144c83e3f69e78fe5a7ea0
Reviewed-on: https://review.typo3.org/55567
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
typo3/sysext/core/Classes/Package/PackageManager.php

index eadbab3..d43183a 100644 (file)
@@ -1042,14 +1042,25 @@ class PackageManager implements \TYPO3\CMS\Core\SingletonInterface
     {
         if (count($this->packagesBasePaths) < 3) {
             // Check if the directory even exists and if it is not empty
-            if (is_dir(PATH_typo3conf . 'ext') && count(scandir(PATH_typo3conf . 'ext')) > 2) {
+            if (is_dir(PATH_typo3conf . 'ext') && $this->hasSubDirectories(PATH_typo3conf . 'ext')) {
                 $this->packagesBasePaths['local'] = PATH_typo3conf . 'ext/*/';
             }
-            if (is_dir(PATH_typo3 . 'ext') && count(scandir(PATH_typo3 . 'ext')) > 2) {
+            if (is_dir(PATH_typo3 . 'ext') && $this->hasSubDirectories(PATH_typo3 . 'ext')) {
                 $this->packagesBasePaths['global'] = PATH_typo3 . 'ext/*/';
             }
             $this->packagesBasePaths['system'] = PATH_typo3 . 'sysext/*/';
         }
         return $this->packagesBasePaths;
     }
+
+    /**
+     * Returns true if the given path has valid subdirectories, false otherwise.
+     *
+     * @param string $path
+     * @return bool
+     */
+    protected function hasSubDirectories(string $path): bool
+    {
+        return !empty(glob(rtrim($path, '/\\') . '/*', GLOB_ONLYDIR));
+    }
 }