Revert "[BUGFIX] Fix loading order for extensions" 98/31098/2
authorMarkus Klein <klein.t3@mfc-linz.at>
Tue, 24 Jun 2014 01:12:29 +0000 (03:12 +0200)
committerMarkus Klein <klein.t3@mfc-linz.at>
Tue, 24 Jun 2014 01:15:58 +0000 (03:15 +0200)
This reverts commit c0779513b431b19413873893bf630aa3de6fc1fc

The patch has two flaws:
 * Easy: packagePathStack also includes package folder which
         is incompatible to the excludedPaths search
 * Nightmare: Upon uninstalling extensions the PackageManager
         fails due to missing packagePathStack information

Change-Id: I27642b3dea7541cb5f7363172edff147d34999d1
Resolves: #59831
Reverts: #59147
Releases: 6.3, 6.2
Reviewed-on: https://review.typo3.org/31098
Reviewed-by: Markus Klein
Tested-by: Markus Klein
typo3/sysext/core/Classes/Package/DependencyResolver.php
typo3/sysext/core/Classes/Package/PackageManager.php
typo3/sysext/core/Tests/Unit/Package/DependencyResolverTest.php

index b7e98f4..f98b42a 100644 (file)
@@ -271,9 +271,15 @@ class DependencyResolver {
        protected function getPackageKeysInBasePath(array $packageStateConfiguration, $basePath, array $excludedPaths = array()) {
                $packageKeys = array();
                foreach ($packageStateConfiguration as $packageKey => $package) {
-                       if ($basePath === '' || in_array($basePath, $package['packagePathStack'], TRUE)) {
-                               $containedExcludedPaths = array_intersect($package['packagePathStack'], $excludedPaths);
-                               if (empty($containedExcludedPaths)) {
+                       if (($basePath === '' || strpos($package['packagePath'], $basePath) === 0)) {
+                               $isExcluded = FALSE;
+                               foreach ($excludedPaths as $excludedPath) {
+                                       if (strpos($package['packagePath'], $excludedPath) === 0) {
+                                               $isExcluded = TRUE;
+                                               break;
+                                       }
+                               }
+                               if (!$isExcluded) {
                                        $packageKeys[] = $packageKey;
                                }
                        }
@@ -281,4 +287,4 @@ class DependencyResolver {
                return $packageKeys;
        }
 
-}
\ No newline at end of file
+}
index 1555f3c..fb713d1 100644 (file)
@@ -83,9 +83,9 @@ class PackageManager extends \TYPO3\Flow\Package\PackageManager implements \TYPO
         */
        public function __construct() {
                $this->packagesBasePaths = array(
-                       'sysext'    => PATH_typo3 . 'sysext',
-                       'global'    => PATH_typo3 . 'ext',
                        'local'     => PATH_typo3conf . 'ext',
+                       'global'    => PATH_typo3 . 'ext',
+                       'sysext'    => PATH_typo3 . 'sysext',
                        'composer'  => PATH_site . 'Packages',
                );
                $this->packageStatesPathAndFilename = PATH_typo3conf . 'PackageStates.php';
@@ -384,10 +384,6 @@ class PackageManager extends \TYPO3\Flow\Package\PackageManager implements \TYPO
                        }
 
                        $this->packageStatesConfiguration['packages'][$packageKey]['packagePath'] = str_replace($this->packagesBasePath, '', $packagePath);
-                       // An extension might be overwritten by another one. (eg sysext overwritten with ext)
-                       // We have to remember which paths we found the extension in as
-                       // we need to know this in the DependencyResolver later.
-                       $this->packageStatesConfiguration['packages'][$packageKey]['packagePathStack'][] = $this->packageStatesConfiguration['packages'][$packageKey]['packagePath'];
 
                        // Change this to read the target from Composer or any other source
                        $this->packageStatesConfiguration['packages'][$packageKey]['classesPath'] = Package::DIRECTORY_CLASSES;
@@ -707,9 +703,6 @@ class PackageManager extends \TYPO3\Flow\Package\PackageManager implements \TYPO
                $newPackages = array();
                foreach (array_keys($this->packageStatesConfiguration['packages']) as $packageKey) {
                        $newPackages[$packageKey] = $this->packages[$packageKey];
-                       // Remove the packagePathStack here again. We don't need it anymore and
-                       // we don't want it in the package states file
-                       unset($this->packageStatesConfiguration['packages'][$packageKey]['packagePathStack']);
                }
                $this->packages = $newPackages;
        }
index b9de6a2..c9afedb 100644 (file)
@@ -84,15 +84,22 @@ class DependencyResolverTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                        'A' => array(
                                'state' => 'active',
                                'dependencies' => array('B'),
-                               'packagePathStack' => array('foo')
                        ),
                        'B' => array(
                                'state' => 'active',
-                               'dependencies' => array('A'),
-                               'packagePathStack' => array('foo')
+                               'dependencies' => array('A')
                        ),
                );
-               $dependencyResolver = $this->getAccessibleMock('\TYPO3\CMS\Core\Package\DependencyResolver', array('dummy'));
+
+               $packageKeys = array_keys($unsortedPackageStatesConfiguration);
+
+               $basePathAssignment = array(
+                       array($unsortedPackageStatesConfiguration, '', array(DependencyResolver::SYSEXT_FOLDER), $packageKeys),
+                       array($unsortedPackageStatesConfiguration, DependencyResolver::SYSEXT_FOLDER, array(), array()),
+               );
+
+               $dependencyResolver = $this->getAccessibleMock('\TYPO3\CMS\Core\Package\DependencyResolver', array('getActivePackageKeysOfType'));
+               $dependencyResolver->expects($this->any())->method('getActivePackageKeysOfType')->will($this->returnValueMap($basePathAssignment));
                $dependencyResolver->_call('sortPackageStatesConfigurationByDependency', $unsortedPackageStatesConfiguration);
        }
 
@@ -868,94 +875,4 @@ class DependencyResolverTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $this->assertSame($expected, $path);
        }
 
-       /**
-        * Data provider for getPackageKeysInBasePathReturnsCorrectKeys
-        * @return array
-        */
-       public function getPackageKeysInBasePathReturnsCorrectKeysDataProvider() {
-               return array(
-                       'Single paths only, include all' => array(
-                               array(
-                                       'key1' => array('packagePathStack' => array(DependencyResolver::SYSEXT_FOLDER)),
-                                       'key2' => array('packagePathStack' => array('somewhereelse')),
-                                       'key3' => array('packagePathStack' => array(DependencyResolver::SYSEXT_FOLDER)),
-                               ),
-                               '',
-                               array(),
-                               array('key1', 'key2', 'key3')
-                       ),
-                       'Single paths only, include sysext' => array(
-                               array(
-                                       'key1' => array('packagePathStack' => array(DependencyResolver::SYSEXT_FOLDER)),
-                                       'key2' => array('packagePathStack' => array('somewhereelse')),
-                                       'key3' => array('packagePathStack' => array(DependencyResolver::SYSEXT_FOLDER)),
-                               ),
-                               DependencyResolver::SYSEXT_FOLDER,
-                               array(),
-                               array('key1', 'key3')
-                       ),
-                       'Single paths only, exclude sysext' => array(
-                               array(
-                                       'key1' => array('packagePathStack' => array(DependencyResolver::SYSEXT_FOLDER)),
-                                       'key2' => array('packagePathStack' => array('somewhereelse')),
-                                       'key3' => array('packagePathStack' => array(DependencyResolver::SYSEXT_FOLDER)),
-                               ),
-                               '',
-                               array(DependencyResolver::SYSEXT_FOLDER),
-                               array('key2')
-                       ),
-                       'Multiple paths, include sysext' => array(
-                               array(
-                                       'key1' => array('packagePathStack' => array(DependencyResolver::SYSEXT_FOLDER, 'somewhereelse')),
-                                       'key2' => array('packagePathStack' => array('somewhereelse')),
-                                       'key3' => array('packagePathStack' => array(DependencyResolver::SYSEXT_FOLDER)),
-                               ),
-                               DependencyResolver::SYSEXT_FOLDER,
-                               array(),
-                               array('key1', 'key3')
-                       ),
-                       'Multiple paths, exclude sysext' => array(
-                               array(
-                                       'key1' => array('packagePathStack' => array(DependencyResolver::SYSEXT_FOLDER, 'somewhereelse')),
-                                       'key2' => array('packagePathStack' => array('somewhereelse')),
-                                       'key3' => array('packagePathStack' => array(DependencyResolver::SYSEXT_FOLDER)),
-                                       'key4' => array('packagePathStack' => array('elsewhere')),
-                               ),
-                               '',
-                               array(DependencyResolver::SYSEXT_FOLDER),
-                               array('key2', 'key4')
-                       ),
-                       'Multiple paths, include somewhereelse' => array(
-                               array(
-                                       'key1' => array('packagePathStack' => array(DependencyResolver::SYSEXT_FOLDER, 'somewhereelse')),
-                                       'key2' => array('packagePathStack' => array('somewhereelse')),
-                                       'key3' => array('packagePathStack' => array(DependencyResolver::SYSEXT_FOLDER)),
-                               ),
-                               'somewhereelse',
-                               array(),
-                               array('key1', 'key2')
-                       ),
-                       'Multiple paths, include somewhereelse, exclude sysext' => array(
-                               array(
-                                       'key1' => array('packagePathStack' => array(DependencyResolver::SYSEXT_FOLDER, 'somewhereelse')),
-                                       'key2' => array('packagePathStack' => array('somewhereelse')),
-                                       'key3' => array('packagePathStack' => array(DependencyResolver::SYSEXT_FOLDER)),
-                                       'key4' => array('packagePathStack' => array('elsewhere')),
-                               ),
-                               'somewhereelse',
-                               array(DependencyResolver::SYSEXT_FOLDER),
-                               array('key2')
-                       ),
-               );
-       }
-
-       /**
-        * @test
-        * @dataProvider getPackageKeysInBasePathReturnsCorrectKeysDataProvider
-        */
-       public function getPackageKeysInBasePathReturnsCorrectKeys(array $packageStates, $include, array $exclude, array $expectedKeys) {
-               $dependencyResolver = $this->getAccessibleMock('\TYPO3\CMS\Core\Package\DependencyResolver', array('dummy'));
-               $keys = $dependencyResolver->_call('getPackageKeysInBasePath', $packageStates, $include, $exclude);
-               $this->assertSame($expectedKeys, $keys);
-       }
 }