[BUGFIX] Always throw exception if ext_emconf.php is missing 50/50050/3
authorHelmut Hummel <info@helhum.io>
Mon, 26 Sep 2016 13:03:17 +0000 (15:03 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Wed, 28 Sep 2016 12:46:21 +0000 (14:46 +0200)
The ext_emconf.php is still required for TYPO3 extensions.
However a piece of PackageManager code was still graceful
if instead at least a composer.json was present.

Then however it failed, when in composer.json the require section
was filled with composer packages which are unknown to TYPO3.

Because of this, we need to throw an exception in any case,
if ext_emconf.php is not present.

Resolves: #78054
Releases: 7.6, master
Change-Id: I08b9931dac50384e08fe89558288fa8653722a78
Reviewed-on: https://review.typo3.org/50050
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Helmut Hummel <typo3@helhum.io>
Tested-by: Helmut Hummel <typo3@helhum.io>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/core/Classes/Package/PackageManager.php
typo3/sysext/core/Tests/Unit/Package/PackageManagerTest.php

index 6603f54..37ccc1c 100644 (file)
@@ -936,7 +936,6 @@ class PackageManager implements \TYPO3\CMS\Core\SingletonInterface
      *
      * @param string $manifestPath
      * @return \stdClass
-     * @throws Exception\MissingPackageManifestException
      * @throws Exception\InvalidPackageManifestException
      */
     public function getComposerManifest($manifestPath)
@@ -950,18 +949,12 @@ class PackageManager implements \TYPO3\CMS\Core\SingletonInterface
             }
         }
 
-        try {
-            $extensionManagerConfiguration = $this->getExtensionEmConf($manifestPath);
-            $composerManifest = $this->mapExtensionManagerConfigurationToComposerManifest(
-                basename($manifestPath),
-                $extensionManagerConfiguration,
-                $composerManifest ?: new \stdClass()
-            );
-        } catch (Exception\InvalidPackageManifestException $e) {
-            if ($composerManifest === null) {
-                throw $e;
-            }
-        }
+        $extensionManagerConfiguration = $this->getExtensionEmConf($manifestPath);
+        $composerManifest = $this->mapExtensionManagerConfigurationToComposerManifest(
+            basename($manifestPath),
+            $extensionManagerConfiguration,
+            $composerManifest ?: new \stdClass()
+        );
 
         return $composerManifest;
     }
index bf0ab02..820a642 100644 (file)
@@ -68,7 +68,7 @@ class PackageManagerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     {
         $packagePath = 'vfs://Test/Packages/Application/' . $packageKey . '/';
         mkdir($packagePath, 0770, true);
-        file_put_contents($packagePath . 'ext_emconf.php', '');
+        file_put_contents($packagePath . 'ext_emconf.php', '<?php' . LF . '$EM_CONF[$_EXTKEY] = [];');
         file_put_contents($packagePath . 'composer.json', '{}');
         $package = new Package($this->packageManager, $packageKey, $packagePath);
         $this->packageManager->registerPackage($package);
@@ -145,7 +145,7 @@ class PackageManagerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
 
             mkdir($packagePath, 0770, true);
             file_put_contents($packagePath . 'composer.json', '{"name": "' . $packageKey . '", "type": "typo3-cms-test"}');
-            file_put_contents($packagePath . 'ext_emconf.php', '');
+            file_put_contents($packagePath . 'ext_emconf.php', '<?php' . LF . '$EM_CONF[$_EXTKEY] = [];');
         }
 
         /** @var PackageManager|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface $packageManager */
@@ -196,7 +196,7 @@ class PackageManagerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
 
             mkdir($packagePath, 0770, true);
             file_put_contents($packagePath . 'composer.json', '{"name": "' . $packageKey . '", "type": "typo3-cms-test"}');
-            file_put_contents($packagePath . 'ext_emconf.php', '');
+            file_put_contents($packagePath . 'ext_emconf.php', '<?php' . LF . '$EM_CONF[$_EXTKEY] = [];');
         }
 
         /** @var PackageManager|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface $packageManager */