[BUGFIX] Always throw exception if ext_emconf.php is missing 26/50026/8
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 10:57:13 +0000 (12:57 +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/50026
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Robert van Kammen <rvkammen@hotmail.com>
Tested-by: Robert van Kammen <rvkammen@hotmail.com>
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 de2f4b4..2520a18 100644 (file)
@@ -843,7 +843,6 @@ class PackageManager implements \TYPO3\CMS\Core\SingletonInterface
      *
      * @param string $manifestPath
      * @return \stdClass
-     * @throws Exception\MissingPackageManifestException
      * @throws Exception\InvalidPackageManifestException
      */
     public function getComposerManifest($manifestPath)
@@ -857,18 +856,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 cf51fd6..c42aaeb 100644 (file)
@@ -76,7 +76,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);
@@ -157,7 +157,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 */
@@ -208,7 +208,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] = [];');
             $packagePaths[] = $packagePath;
         }