From 143c274496c566f80e3481050bcd54408e3fba58 Mon Sep 17 00:00:00 2001 From: Markus Klein <klein.t3@mfc-linz.at> Date: Tue, 24 Jun 2014 03:10:55 +0200 Subject: [PATCH] Revert "[BUGFIX] Fix loading order for extensions" This reverts commit 49b53d491e43f3ad7a4c30dc23e208eb8db04199 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: Ie026a90bd18ab86c355c17ae387df9249bc6b1c0 Resolves: #59831 Reverts: #59147 Releases: 6.3, 6.2 Reviewed-on: https://review.typo3.org/31097 Reviewed-by: Markus Klein Tested-by: Markus Klein --- .../Classes/Package/DependencyResolver.php | 14 ++- .../core/Classes/Package/PackageManager.php | 11 +- .../Unit/Package/DependencyResolverTest.php | 105 ++---------------- 3 files changed, 23 insertions(+), 107 deletions(-) diff --git a/typo3/sysext/core/Classes/Package/DependencyResolver.php b/typo3/sysext/core/Classes/Package/DependencyResolver.php index b7e98f467b9c..f98b42a07284 100644 --- a/typo3/sysext/core/Classes/Package/DependencyResolver.php +++ b/typo3/sysext/core/Classes/Package/DependencyResolver.php @@ -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 +} diff --git a/typo3/sysext/core/Classes/Package/PackageManager.php b/typo3/sysext/core/Classes/Package/PackageManager.php index 1555f3c17ff7..fb713d1206e4 100644 --- a/typo3/sysext/core/Classes/Package/PackageManager.php +++ b/typo3/sysext/core/Classes/Package/PackageManager.php @@ -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; } diff --git a/typo3/sysext/core/Tests/Unit/Package/DependencyResolverTest.php b/typo3/sysext/core/Tests/Unit/Package/DependencyResolverTest.php index b9de6a24097a..c9afedbe6148 100644 --- a/typo3/sysext/core/Tests/Unit/Package/DependencyResolverTest.php +++ b/typo3/sysext/core/Tests/Unit/Package/DependencyResolverTest.php @@ -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); - } } -- GitLab