[BUGFIX] Fix dependencies for non-composer extensions 19/26619/3
authorThomas Maroschik <tmaroschik@dfau.de>
Thu, 2 Jan 2014 11:01:07 +0000 (12:01 +0100)
committerOliver Hader <oliver.hader@typo3.org>
Tue, 7 Jan 2014 13:35:53 +0000 (14:35 +0100)
The method packageRequirementIsComposerPackage of
TYPO3\CMS\Core\Package ignores all non composer package
names and thus dependency resolving of non composer packages
doesn't work.

This patch adapts the behavior to ignore just the platform
package links described here
http://getcomposer.org/doc/02-libraries.md#platform-packages

Fixes: #54142
Releases: 6.2
Change-Id: Idb6a837eebf792c6cbf9394885edc17c9d392a9f
Reviewed-on: https://review.typo3.org/26619
Reviewed-by: Stefan Froemken
Tested-by: Stefan Froemken
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
Reviewed-by: Markus Klein
Tested-by: Markus Klein
Reviewed-by: Oliver Hader
Tested-by: Oliver Hader
typo3/sysext/core/Classes/Package/Package.php
typo3/sysext/core/Classes/Package/PackageManager.php
typo3/sysext/core/Tests/Unit/Package/PackageManagerTest.php

index 502698e..2163338 100644 (file)
@@ -241,11 +241,11 @@ class Package extends \TYPO3\Flow\Package\Package implements PackageInterface {
         * @return boolean TRUE if $requirement is a composer package (contains a slash), FALSE otherwise
         */
        protected function packageRequirementIsComposerPackage($requirement) {
-               //@TODO remove this workaround once extensionmanager can handle composer packages natively
-               if ($requirement === 'composer/installers') {
-                       return FALSE;
-               }
-               return parent::packageRequirementIsComposerPackage($requirement);
+               // According to http://getcomposer.org/doc/02-libraries.md#platform-packages
+               // the following regex should capture all non composer requirements.
+               // typo3 is included in the list because it's a meta package and not supported for now.
+               // composer/installers is included until extensionmanager can handle composer packages natively
+               return preg_match('/^(php(-64bit)?|ext-[^\/]+|lib-(curl|iconv|libxml|openssl|pcre|uuid|xsl)|typo3|composer\/installers)$/', $requirement) !== 1;
        }
 
 
index 6486667..23a84d1 100644 (file)
@@ -608,9 +608,9 @@ class PackageManager extends \TYPO3\Flow\Package\PackageManager implements \TYPO
         * @param array $excludedTypes Array of package types to exclude
         * @return array List of packages
         */
-       protected function getPackageKeysOfType($type, array $excludedTypes = array()) {
+       protected function getActivePackageKeysOfType($type, array $excludedTypes = array()) {
                $packageKeys = array();
-               foreach ($this->packages as $packageKey => $package) {
+               foreach ($this->activePackages as $packageKey => $package) {
                        $packageType = $package->getComposerManifest('type');
                        if (($type === '' || $packageType === $type) && !in_array($packageType, $excludedTypes)) {
                                $packageKeys[] = $packageKey;
@@ -656,8 +656,8 @@ class PackageManager extends \TYPO3\Flow\Package\PackageManager implements \TYPO
                                $rootPackageKeys[] = $packageKey;
                        }
                }
-               $extensionPackageKeys = $this->getPackageKeysOfType('', array('typo3-cms-framework'));
-               $frameworkPackageKeys = $this->getPackageKeysOfType('typo3-cms-framework');
+               $extensionPackageKeys = $this->getActivePackageKeysOfType('', array('typo3-cms-framework'));
+               $frameworkPackageKeys = $this->getActivePackageKeysOfType('typo3-cms-framework');
                foreach ($extensionPackageKeys as $packageKey) {
                        // Remove framework packages from list
                        $packageKeysWithoutFramework = array_diff(
@@ -683,7 +683,7 @@ class PackageManager extends \TYPO3\Flow\Package\PackageManager implements \TYPO
        protected function buildDependencyGraph() {
                $this->resolvePackageDependencies();
 
-               $frameworkPackageKeys = $this->getPackageKeysOfType('typo3-cms-framework');
+               $frameworkPackageKeys = $this->getActivePackageKeysOfType('typo3-cms-framework');
                $this->buildDependencyGraphForPackages($frameworkPackageKeys);
 
                $this->addDependencyToFrameworkToAllExtensions();
index 8a66549..5559035 100644 (file)
@@ -686,8 +686,8 @@ class PackageManagerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                        array('typo3-cms-framework', array(), $frameworkPackageKeys),
                );
 
-               $packageManager = $this->getAccessibleMock('\TYPO3\CMS\Core\Package\PackageManager', array('resolvePackageDependencies','getPackageKeysOfType'));
-               $packageManager->expects($this->any())->method('getPackageKeysOfType')->will($this->returnValueMap($typeAssignment));
+               $packageManager = $this->getAccessibleMock('\TYPO3\CMS\Core\Package\PackageManager', array('resolvePackageDependencies','getActivePackageKeysOfType'));
+               $packageManager->expects($this->any())->method('getActivePackageKeysOfType')->will($this->returnValueMap($typeAssignment));
                $packageManager->_set('packages', $unsortedPackages);
                $packageManager->_set('packageStatesConfiguration', $unsortedPackageStatesConfiguration);
                $packageManager->_call('buildDependencyGraph');
@@ -859,8 +859,8 @@ class PackageManagerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                        array('typo3-cms-framework', array(), $frameworkPackageKeys),
                );
 
-               $packageManager = $this->getAccessibleMock('\TYPO3\CMS\Core\Package\PackageManager', array('resolvePackageDependencies','getPackageKeysOfType'));
-               $packageManager->expects($this->any())->method('getPackageKeysOfType')->will($this->returnValueMap($typeAssignment));
+               $packageManager = $this->getAccessibleMock('\TYPO3\CMS\Core\Package\PackageManager', array('resolvePackageDependencies','getActivePackageKeysOfType'));
+               $packageManager->expects($this->any())->method('getActivePackageKeysOfType')->will($this->returnValueMap($typeAssignment));
                $packageManager->_set('packages', $unsortedPackages);
                $packageManager->_set('packageStatesConfiguration', $unsortedPackageStatesConfiguration);
                $packageManager->_call('sortAvailablePackagesByDependencies');
@@ -1104,8 +1104,8 @@ class PackageManagerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                        array('typo3-cms-framework', array(), array()),
                );
 
-               $packageManager = $this->getAccessibleMock('\TYPO3\CMS\Core\Package\PackageManager', array('resolvePackageDependencies','getPackageKeysOfType'));
-               $packageManager->expects($this->any())->method('getPackageKeysOfType')->will($this->returnValueMap($typeAssignment));
+               $packageManager = $this->getAccessibleMock('\TYPO3\CMS\Core\Package\PackageManager', array('resolvePackageDependencies','getActivePackageKeysOfType'));
+               $packageManager->expects($this->any())->method('getActivePackageKeysOfType')->will($this->returnValueMap($typeAssignment));
                $packageManager->_set('packages', $unsortedPackages);
                $packageManager->_set('packageStatesConfiguration', $unsortedPackageStatesConfiguration);
                $packageManager->_call('getAvailablePackageLoadingOrder');