[TASK] Deprecate $GLOBALS['TYPO3_LOADED_EXT'] 08/58408/6
authorBenjamin Franzke <bfr@qbus.de>
Thu, 27 Sep 2018 08:31:08 +0000 (10:31 +0200)
committerBenni Mack <benni@typo3.org>
Thu, 27 Sep 2018 17:22:55 +0000 (19:22 +0200)
$GLOBALS['TYPO3_LOADED_EXT'] is defined as the "old" way
since the introduction of the PackageManager in 2013:
https://review.typo3.org/19605
(The class description of LoadExtensionArrayElement states:
Class to simulate the "old" extension information array element)

This old way should finally be removed to reduce site effects
(pollution of the global scope) of the PackageManager class.
It's marked as deprecated now, to be removed in v10.

All existing usaged are rewritten to use the PackageManager API.

Releases: master
Resolves: #86404
Change-Id: Ic53f5155828ef2ea711a1961e08f8e020e3f836a
Reviewed-on: https://review.typo3.org/58408
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
19 files changed:
typo3/sysext/core/Classes/Database/Schema/SqlReader.php
typo3/sysext/core/Classes/Package/PackageManager.php
typo3/sysext/core/Classes/TypoScript/TemplateService.php
typo3/sysext/core/Classes/Utility/ExtensionManagementUtility.php
typo3/sysext/core/Documentation/Changelog/master/Deprecation-86404-DeprecateGLOBALSTYPO3_LOADED_EXT.rst [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Database/Schema/Parser/TableBuilderTest.php
typo3/sysext/core/Tests/Unit/Database/Schema/SqlReaderTest.php
typo3/sysext/core/Tests/Unit/TypoScript/TemplateServiceTest.php
typo3/sysext/core/Tests/Unit/Utility/ExtensionManagementUtilityTest.php
typo3/sysext/core/Tests/UnitDeprecated/TypoScript/TemplateServiceTest.php
typo3/sysext/core/Tests/UnitDeprecated/Utility/ExtensionManagementUtilityTest.php
typo3/sysext/extbase/Tests/Unit/Utility/ExtensionUtilityTest.php
typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php
typo3/sysext/frontend/Tests/Unit/ContentObject/FilesContentObjectTest.php
typo3/sysext/install/Classes/Controller/UpgradeController.php
typo3/sysext/install/Classes/Service/LoadTcaService.php
typo3/sysext/install/Configuration/ExtensionScanner/Php/ArrayGlobalMatcher.php
typo3/sysext/install/Tests/Unit/Controller/UpgradeControllerTest.php
typo3/sysext/lowlevel/Classes/Controller/ConfigurationController.php

index 918451e..c0b7298 100644 (file)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Core\Database\Schema;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Package\PackageManager;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\SignalSlot\Dispatcher;
 
@@ -27,17 +28,24 @@ use TYPO3\CMS\Extbase\SignalSlot\Dispatcher;
 class SqlReader
 {
     /**
-     * @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher
+     * @var Dispatcher
      */
     protected $signalSlotDispatcher;
 
     /**
+     * @var PackageManager
+     */
+    protected $packageManager;
+
+    /**
      * @param Dispatcher $signalSlotDispatcher
+     * @param PackageManager $packageManager
      * @throws \InvalidArgumentException
      */
-    public function __construct(Dispatcher $signalSlotDispatcher = null)
+    public function __construct(Dispatcher $signalSlotDispatcher = null, PackageManager $packageManager = null)
     {
         $this->signalSlotDispatcher = $signalSlotDispatcher ?: GeneralUtility::makeInstance(Dispatcher::class);
+        $this->packageManager = $packageManager ?? GeneralUtility::makeInstance(PackageManager::class);
     }
 
     /**
@@ -54,15 +62,13 @@ class SqlReader
         $sqlString = [];
 
         // Find all ext_tables.sql of loaded extensions
-        foreach ((array)$GLOBALS['TYPO3_LOADED_EXT'] as $extensionConfiguration) {
-            if (!is_array($extensionConfiguration) && !$extensionConfiguration instanceof \ArrayAccess) {
-                continue;
-            }
-            if ($extensionConfiguration['ext_tables.sql']) {
-                $sqlString[] = file_get_contents($extensionConfiguration['ext_tables.sql']);
+        foreach ($this->packageManager->getActivePackages() as $package) {
+            $packagePath = $package->getPackagePath();
+            if (@file_exists($packagePath . 'ext_tables.sql')) {
+                $sqlString[] = file_get_contents($packagePath . 'ext_tables.sql');
             }
-            if ($withStatic && $extensionConfiguration['ext_tables_static+adt.sql']) {
-                $sqlString[] = file_get_contents($extensionConfiguration['ext_tables_static+adt.sql']);
+            if ($withStatic && @file_exists($packagePath . 'ext_tables_static+adt.sql')) {
+                $sqlString[] = file_get_contents($packagePath . 'ext_tables_static+adt.sql');
             }
         }
 
index 8e9a0f1..b882b80 100644 (file)
@@ -143,6 +143,7 @@ class PackageManager implements SingletonInterface
         } catch (Exception\PackageManagerCacheUnavailableException $exception) {
             $this->loadPackageStates();
             $this->initializePackageObjects();
+            // @deprecated will be removed in v10
             $this->initializeCompatibilityLoadedExtArray();
             $this->saveToPackageCache();
         }
@@ -184,6 +185,7 @@ class PackageManager implements SingletonInterface
             $packageCache = [
                 'packageStatesConfiguration' => $this->packageStatesConfiguration,
                 'packageAliasMap' => $this->packageAliasMap,
+                // @deprecated will be removed in v10
                 'loadedExtArray' => $GLOBALS['TYPO3_LOADED_EXT'],
                 'composerNameToPackageKeyMap' => $this->composerNameToPackageKeyMap,
                 'packageObjects' => serialize($this->packages),
@@ -220,6 +222,7 @@ class PackageManager implements SingletonInterface
                 \stdClass::class,
             ]
         ]);
+        // @deprecated will be removed in v10
         $GLOBALS['TYPO3_LOADED_EXT'] = $packageCache['loadedExtArray'];
     }
 
@@ -299,6 +302,7 @@ class PackageManager implements SingletonInterface
      */
     protected function initializeCompatibilityLoadedExtArray()
     {
+        // @deprecated will be removed in v10
         $loadedExtObj = new \TYPO3\CMS\Core\Compatibility\LoadedExtensionsArray($this);
         $GLOBALS['TYPO3_LOADED_EXT'] = $loadedExtObj->toArray();
     }
@@ -608,6 +612,7 @@ class PackageManager implements SingletonInterface
     {
         $package = $this->registerPackageDuringRuntime($packageKey);
         $this->runtimeActivatedPackages[$package->getPackageKey()] = $package;
+        // @deprecated will be removed in v10
         if (!isset($GLOBALS['TYPO3_LOADED_EXT'][$package->getPackageKey()])) {
             $loadedExtArrayElement = new LoadedExtensionArrayElement($package);
             $GLOBALS['TYPO3_LOADED_EXT'][$package->getPackageKey()] = $loadedExtArrayElement->toArray();
@@ -790,6 +795,7 @@ class PackageManager implements SingletonInterface
         $packageStatesCode = "<?php\n$fileDescription\nreturn " . ArrayUtility::arrayExport($this->packageStatesConfiguration) . ";\n";
         GeneralUtility::writeFile($this->packageStatesPathAndFilename, $packageStatesCode, true);
 
+        // @deprecated will be removed in v10
         $this->initializeCompatibilityLoadedExtArray();
 
         GeneralUtility::makeInstance(OpcodeCacheService::class)->clearAllActive($this->packageStatesPathAndFilename);
index 19755c6..bf23cb6 100644 (file)
@@ -25,6 +25,7 @@ use TYPO3\CMS\Core\Database\Query\Restriction\AbstractRestrictionContainer;
 use TYPO3\CMS\Core\Database\Query\Restriction\DefaultRestrictionContainer;
 use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
 use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction;
+use TYPO3\CMS\Core\Package\PackageManager;
 use TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException;
 use TYPO3\CMS\Core\Resource\Exception\InvalidFileException;
 use TYPO3\CMS\Core\Resource\Exception\InvalidFileNameException;
@@ -369,11 +370,18 @@ class TemplateService
     protected $context;
 
     /**
+     * @var PackageManager
+     */
+    protected $packageManager;
+
+    /**
      * @param Context|null $context
+     * @param PackageManager|null $packageManager
      */
-    public function __construct(Context $context = null)
+    public function __construct(Context $context = null, PackageManager $packageManager = null)
     {
         $this->context = $context ?? GeneralUtility::makeInstance(Context::class);
+        $this->packageManager = $packageManager ?? GeneralUtility::makeInstance(PackageManager::class);
         $this->initializeDatabaseQueryRestrictions();
         if ($this->context->getPropertyFromAspect('visibility', 'includeHiddenContent', false) || $GLOBALS['SIM_ACCESS_TIME'] !== $GLOBALS['ACCESS_TIME']) {
             // Set the simulation flag, if simulation is detected!
@@ -1009,16 +1017,28 @@ class TemplateService
     {
         $this->extensionStaticsProcessed = true;
 
-        // @todo Change to use new API
-        foreach ($GLOBALS['TYPO3_LOADED_EXT'] as $extKey => $files) {
-            if ((is_array($files) || $files instanceof \ArrayAccess)
-                && (
-                    !empty($files['ext_typoscript_constants.txt'])
-                    || !empty($files['ext_typoscript_constants.typoscript'])
-                    || !empty($files['ext_typoscript_setup.txt'])
-                    || !empty($files['ext_typoscript_setup.typoscript'])
-                )
-            ) {
+        foreach ($this->packageManager->getActivePackages() as $package) {
+            $extKey = $package->getPackageKey();
+            $packagePath = $package->getPackagePath();
+            $filesToCheck = [
+                'ext_typoscript_constants.txt',
+                'ext_typoscript_constants.typoscript',
+                'ext_typoscript_setup.txt',
+                'ext_typoscript_setup.typoscript',
+            ];
+            $files = [];
+            $hasExtensionStatics = false;
+            foreach ($filesToCheck as $file) {
+                $path = $packagePath . $file;
+                if (@file_exists($path)) {
+                    $files[$file] = $path;
+                    $hasExtensionStatics = true;
+                } else {
+                    $files[$file] = null;
+                }
+            }
+
+            if ($hasExtensionStatics) {
                 $mExtKey = str_replace('_', '', $extKey);
                 $constants = '';
                 $config = '';
@@ -1046,7 +1066,7 @@ class TemplateService
                     $pid,
                     'ext_' . $mExtKey,
                     $templateID,
-                    ExtensionManagementUtility::extPath($extKey)
+                    $packagePath
                 );
             }
         }
index 9d58b35..336eebd 100644 (file)
@@ -1236,10 +1236,9 @@ class ExtensionManagementUtility
                 1404068038
             );
         }
-        if ((!isset($itemArray[2]) || !$itemArray[2])
-            && isset($GLOBALS['TYPO3_LOADED_EXT'][$extensionKey]['ext_icon'])
-        ) {
-            $itemArray[2] = 'EXT:' . $extensionKey . '/' . $GLOBALS['TYPO3_LOADED_EXT'][$extensionKey]['ext_icon'];
+        if (!isset($itemArray[2]) || !$itemArray[2]) {
+            // @todo do we really set $itemArray[2], even if we cannot find an icon? (as that means it's set to 'EXT:foobar/')
+            $itemArray[2] = 'EXT:' . $extensionKey . '/' . static::getExtensionIcon(static::$packageManager->getPackage($extensionKey)->getPackagePath());
         }
         if (is_array($GLOBALS['TCA']['tt_content']['columns']) && is_array($GLOBALS['TCA']['tt_content']['columns'][$type]['config']['items'])) {
             foreach ($GLOBALS['TCA']['tt_content']['columns'][$type]['config']['items'] as $k => $v) {
@@ -1558,12 +1557,14 @@ tt_content.' . $key . $suffix . ' {
         // scope but to use $GLOBALS['TYPO3_CONF_VARS'] instead.
         // Nevertheless we define it here as global for backwards compatibility.
         global $TYPO3_CONF_VARS;
-        foreach ($GLOBALS['TYPO3_LOADED_EXT'] as $_EXTKEY => $extensionInformation) {
-            if ((is_array($extensionInformation) || $extensionInformation instanceof \ArrayAccess) && isset($extensionInformation['ext_localconf.php'])) {
+        foreach (static::$packageManager->getActivePackages() as $package) {
+            $extLocalconfPath = $package->getPackagePath() . 'ext_localconf.php';
+            if (@file_exists($extLocalconfPath)) {
                 // $_EXTKEY and $_EXTCONF are available in ext_localconf.php
                 // and are explicitly set in cached file as well
+                $_EXTKEY = $package->getPackageKey();
                 $_EXTCONF = $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$_EXTKEY] ?? null;
-                require $extensionInformation['ext_localconf.php'];
+                require $extLocalconfPath;
             }
         }
     }
@@ -1573,7 +1574,6 @@ tt_content.' . $key . $suffix . ' {
      */
     protected static function createExtLocalconfCacheEntry()
     {
-        $extensionInformation = $GLOBALS['TYPO3_LOADED_EXT'];
         $phpCodeToCache = [];
         // Set same globals as in loadSingleExtLocalconfFiles()
         $phpCodeToCache[] = '/**';
@@ -1583,12 +1583,14 @@ tt_content.' . $key . $suffix . ' {
         $phpCodeToCache[] = 'global $TYPO3_CONF_VARS, $T3_SERVICES, $T3_VAR;';
         $phpCodeToCache[] = '';
         // Iterate through loaded extensions and add ext_localconf content
-        foreach ($extensionInformation as $extensionKey => $extensionDetails) {
-            if (isset($extensionDetails['ext_localconf.php']) && $extensionDetails['ext_localconf.php']) {
+        foreach (static::$packageManager->getActivePackages() as $package) {
+            $extensionKey = $package->getPackageKey();
+            $extLocalconfPath = $package->getPackagePath() . 'ext_localconf.php';
+            if (@file_exists($extLocalconfPath)) {
                 // Include a header per extension to make the cache file more readable
                 $phpCodeToCache[] = '/**';
                 $phpCodeToCache[] = ' * Extension: ' . $extensionKey;
-                $phpCodeToCache[] = ' * File: ' . $extensionDetails['ext_localconf.php'];
+                $phpCodeToCache[] = ' * File: ' . $extLocalconfPath;
                 $phpCodeToCache[] = ' */';
                 $phpCodeToCache[] = '';
                 // Set $_EXTKEY and $_EXTCONF for this extension
@@ -1596,7 +1598,7 @@ tt_content.' . $key . $suffix . ' {
                 $phpCodeToCache[] = '$_EXTCONF = $GLOBALS[\'TYPO3_CONF_VARS\'][\'EXT\'][\'extConf\'][$_EXTKEY] ?? null;';
                 $phpCodeToCache[] = '';
                 // Add ext_localconf.php content of extension
-                $phpCodeToCache[] = trim(file_get_contents($extensionDetails['ext_localconf.php']));
+                $phpCodeToCache[] = trim(file_get_contents($extLocalconfPath));
                 $phpCodeToCache[] = '';
                 $phpCodeToCache[] = '';
             }
@@ -1804,12 +1806,14 @@ tt_content.' . $key . $suffix . ' {
         global $PAGES_TYPES, $TBE_STYLES;
         global $_EXTKEY;
         // Load each ext_tables.php file of loaded extensions
-        foreach ($GLOBALS['TYPO3_LOADED_EXT'] as $_EXTKEY => $extensionInformation) {
-            if ((is_array($extensionInformation) || $extensionInformation instanceof \ArrayAccess) && !empty($extensionInformation['ext_tables.php'])) {
+        foreach (static::$packageManager->getActivePackages() as $package) {
+            $extTablesPath = $package->getPackagePath() . 'ext_tables.php';
+            if (@file_exists($extTablesPath)) {
                 // $_EXTKEY and $_EXTCONF are available in ext_tables.php
                 // and are explicitly set in cached file as well
+                $_EXTKEY = $package->getPackageKey();
                 $_EXTCONF = $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$_EXTKEY] ?? null;
-                require $extensionInformation['ext_tables.php'];
+                require $extTablesPath;
             }
         }
     }
@@ -1819,7 +1823,6 @@ tt_content.' . $key . $suffix . ' {
      */
     protected static function createExtTablesCacheEntry()
     {
-        $extensionInformation = $GLOBALS['TYPO3_LOADED_EXT'];
         $phpCodeToCache = [];
         // Set same globals as in loadSingleExtTablesFiles()
         $phpCodeToCache[] = '/**';
@@ -1832,12 +1835,14 @@ tt_content.' . $key . $suffix . ' {
         $phpCodeToCache[] = 'global $_EXTKEY;';
         $phpCodeToCache[] = '';
         // Iterate through loaded extensions and add ext_tables content
-        foreach ($extensionInformation as $extensionKey => $extensionDetails) {
-            if (isset($extensionDetails['ext_tables.php']) && $extensionDetails['ext_tables.php']) {
+        foreach (static::$packageManager->getActivePackages() as $package) {
+            $extensionKey = $package->getPackageKey();
+            $extTablesPath = $package->getPackagePath() . 'ext_tables.php';
+            if (@file_exists($extTablesPath)) {
                 // Include a header per extension to make the cache file more readable
                 $phpCodeToCache[] = '/**';
                 $phpCodeToCache[] = ' * Extension: ' . $extensionKey;
-                $phpCodeToCache[] = ' * File: ' . $extensionDetails['ext_tables.php'];
+                $phpCodeToCache[] = ' * File: ' . $extTablesPath;
                 $phpCodeToCache[] = ' */';
                 $phpCodeToCache[] = '';
                 // Set $_EXTKEY and $_EXTCONF for this extension
@@ -1845,7 +1850,7 @@ tt_content.' . $key . $suffix . ' {
                 $phpCodeToCache[] = '$_EXTCONF = $GLOBALS[\'TYPO3_CONF_VARS\'][\'EXT\'][\'extConf\'][$_EXTKEY] ?? null;';
                 $phpCodeToCache[] = '';
                 // Add ext_tables.php content of extension
-                $phpCodeToCache[] = trim(file_get_contents($extensionDetails['ext_tables.php']));
+                $phpCodeToCache[] = trim(file_get_contents($extTablesPath));
                 $phpCodeToCache[] = '';
             }
         }
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-86404-DeprecateGLOBALSTYPO3_LOADED_EXT.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-86404-DeprecateGLOBALSTYPO3_LOADED_EXT.rst
new file mode 100644 (file)
index 0000000..2e1c6a9
--- /dev/null
@@ -0,0 +1,35 @@
+.. include:: ../../Includes.txt
+
+============================================================
+Deprecation: #86404 - Deprecate $GLOBALS['TYPO3_LOADED_EXT']
+============================================================
+
+See :issue:`86404`
+
+Description
+===========
+
+The global :php:`$GLOBALS['TYPO3_LOADED_EXT']` has been deprecated in favor
+of the :php:`PackageManager` API.
+
+
+Impact
+======
+
+Accessing :php:`$GLOBALS['TYPO3_LOADED_EXT']` is discouraged.
+
+
+Affected Installations
+======================
+
+Instances with extensions using :php:`$GLOBALS['TYPO3_LOADED_EXT']`.
+
+
+Migration
+=========
+
+Use the :php:`getActivePackages()` method of
+:php:`\TYPO3\CMS\Core\Package\PackageManager` to get a list of active
+packages.
+
+.. index:: PHP-API, FullyScanned
index a26bb24..37a940d 100644 (file)
@@ -24,6 +24,7 @@ use Doctrine\DBAL\Types\SmallIntType;
 use Doctrine\DBAL\Types\TextType;
 use TYPO3\CMS\Core\Database\Schema\Parser\Parser;
 use TYPO3\CMS\Core\Database\Schema\SqlReader;
+use TYPO3\CMS\Core\Package\PackageManager;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
@@ -48,7 +49,8 @@ class TableBuilderTest extends UnitTestCase
     {
         parent::setUp();
         $sqlFile = file_get_contents(implode(DIRECTORY_SEPARATOR, [__DIR__, '..', 'Fixtures', 'tablebuilder.sql']));
-        $sqlReader = new SqlReader();
+        $packageManagerProphecy = $this->prophesize(PackageManager::class);
+        $sqlReader = new SqlReader(null, $packageManagerProphecy->reveal());
         $statements = $sqlReader->getCreateTableStatementArray($sqlFile);
 
         $parser = new Parser($statements[0]);
index 9d3b945..b15bcb6 100644 (file)
@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Core\Tests\Unit\Database\Schema;
  */
 
 use TYPO3\CMS\Core\Database\Schema\SqlReader;
+use TYPO3\CMS\Core\Package\PackageManager;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
@@ -34,7 +35,7 @@ class SqlReaderTest extends UnitTestCase
      */
     public function getStatementArraySplitsStatements()
     {
-        $subject = new SqlReader();
+        $subject = new SqlReader(null, $this->prophesize(PackageManager::class)->reveal());
         $result = $subject->getStatementArray(
             'CREATE TABLE aTestTable(' . LF . '  aTestField INT(11)' . LF . ');' .
             LF .
@@ -50,7 +51,7 @@ class SqlReaderTest extends UnitTestCase
      */
     public function getStatementArrayFiltersStatements()
     {
-        $subject = new SqlReader();
+        $subject = new SqlReader(null, $this->prophesize(PackageManager::class)->reveal());
         $result = $subject->getStatementArray(
             'CREATE TABLE aTestTable(' . LF . '  aTestField INT(11)' . LF . ');' .
             LF .
@@ -66,7 +67,7 @@ class SqlReaderTest extends UnitTestCase
      */
     public function getInsertStatementArrayResult()
     {
-        $subject = new SqlReader();
+        $subject = new SqlReader(null, $this->prophesize(PackageManager::class)->reveal());
         $result = $subject->getInsertStatementArray(
             'CREATE TABLE aTestTable(' . LF . '  aTestField INT(11)' . LF . ');' .
             LF .
@@ -82,7 +83,7 @@ class SqlReaderTest extends UnitTestCase
      */
     public function getInsertStatementArrayResultWithNewline()
     {
-        $subject = new SqlReader();
+        $subject = new SqlReader(null, $this->prophesize(PackageManager::class)->reveal());
         $result = $subject->getInsertStatementArray(
             'CREATE TABLE aTestTable(' . LF . '  aTestField INT(11)' . LF . ');' .
             LF .
@@ -100,7 +101,7 @@ class SqlReaderTest extends UnitTestCase
      */
     public function getCreateTableStatementArrayResult()
     {
-        $subject = new SqlReader();
+        $subject = new SqlReader(null, $this->prophesize(PackageManager::class)->reveal());
         $result = $subject->getCreateTableStatementArray(
             'CREATE TABLE aTestTable(' . LF . '  aTestField INT(11)' . LF . ');' .
             LF .
index 0fd540d..6af6725 100644 (file)
@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Core\Tests\Unit\TypoScript;
  */
 
 use Prophecy\Argument;
+use Prophecy\Prophecy\ObjectProphecy;
 use TYPO3\CMS\Core\Context\Context;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\QueryBuilder;
@@ -51,18 +52,23 @@ class TemplateServiceTest extends UnitTestCase
     protected $backupPackageManager;
 
     /**
+     * @var PackageManager|ObjectProphecy
+     */
+    protected $packageManagerProphecy;
+
+    /**
      * Set up
      */
     protected function setUp(): void
     {
-        $GLOBALS['TYPO3_LOADED_EXT'] = [];
         $GLOBALS['SIM_ACCESS_TIME'] = time();
         $GLOBALS['ACCESS_TIME'] = time();
-        $this->templateService = new TemplateService(new Context());
+        $this->packageManagerProphecy = $this->prophesize(PackageManager::class);
+        $this->templateService = new TemplateService(new Context(), $this->packageManagerProphecy->reveal());
         $this->templateServiceMock = $this->getAccessibleMock(
             TemplateService::class,
             ['dummy'],
-            [new Context()]
+            [new Context(), $this->packageManagerProphecy->reveal()]
         );
         $this->backupPackageManager = ExtensionManagementUtilityAccessibleProxy::getPackageManager();
     }
@@ -100,14 +106,7 @@ class TemplateServiceTest extends UnitTestCase
         GeneralUtility::addInstance(ConnectionPool::class, $connectionPoolProphet->reveal());
 
         $identifier = $this->getUniqueId('test');
-        $GLOBALS['TYPO3_LOADED_EXT'] = [
-            $identifier => [
-                'ext_typoscript_setup.txt' => ExtensionManagementUtility::extPath(
-                    'core',
-                    'Tests/Unit/TypoScript/Fixtures/ext_typoscript_setup.txt'
-                ),
-            ],
-        ];
+        $this->packageManagerProphecy->getActivePackages()->shouldNotBeCalled();
 
         $this->templateService->runThroughTemplates([], 0);
         $this->assertFalse(
@@ -126,21 +125,13 @@ class TemplateServiceTest extends UnitTestCase
         GeneralUtility::addInstance(ConnectionPool::class, $connectionPoolProphet->reveal());
 
         $identifier = $this->getUniqueId('test');
-        $GLOBALS['TYPO3_LOADED_EXT'] = [
-            $identifier => [
-                'ext_typoscript_setup.txt' => ExtensionManagementUtility::extPath(
-                    'core',
-                    'Tests/Unit/TypoScript/Fixtures/ext_typoscript_setup.txt'
-                ),
-                'ext_typoscript_constants.txt' => ''
-            ],
-        ];
 
         $mockPackage = $this->getMockBuilder(Package::class)
-            ->setMethods(['getPackagePath'])
+            ->setMethods(['getPackagePath', 'getPackageKey'])
             ->disableOriginalConstructor()
             ->getMock();
-        $mockPackage->expects($this->any())->method('getPackagePath')->will($this->returnValue(''));
+        $mockPackage->expects($this->any())->method('getPackagePath')->will($this->returnValue(__DIR__ . '/Fixtures/'));
+        $mockPackage->expects($this->any())->method('getPackageKey')->will($this->returnValue('core'));
 
         $mockPackageManager = $this->getMockBuilder(PackageManager::class)
             ->setMethods(['isPackageActive', 'getPackage'])
@@ -149,6 +140,7 @@ class TemplateServiceTest extends UnitTestCase
         $mockPackageManager->expects($this->any())->method('isPackageActive')->will($this->returnValue(true));
         $mockPackageManager->expects($this->any())->method('getPackage')->will($this->returnValue($mockPackage));
         ExtensionManagementUtility::setPackageManager($mockPackageManager);
+        $this->packageManagerProphecy->getActivePackages()->willReturn(['core' => $mockPackage]);
 
         $this->templateService->setProcessExtensionStatics(true);
         $this->templateService->runThroughTemplates([], 0);
index 9ca28ab..1b15bf3 100644 (file)
@@ -17,7 +17,6 @@ namespace TYPO3\CMS\Core\Tests\Unit\Utility;
 use TYPO3\CMS\Core\Cache\CacheManager;
 use TYPO3\CMS\Core\Cache\Frontend\PhpFrontend;
 use TYPO3\CMS\Core\Category\CategoryRegistry;
-use TYPO3\CMS\Core\Compatibility\LoadedExtensionsArray;
 use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Package\MetaData;
 use TYPO3\CMS\Core\Package\Package;
@@ -58,7 +57,6 @@ class ExtensionManagementUtilityTest extends UnitTestCase
         ExtensionManagementUtility::clearExtensionKeyMap();
         ExtensionManagementUtilityAccessibleProxy::setPackageManager($this->backUpPackageManager);
         ExtensionManagementUtilityAccessibleProxy::setCacheManager(null);
-        $GLOBALS['TYPO3_LOADED_EXT'] = new LoadedExtensionsArray($this->backUpPackageManager);
         parent::tearDown();
     }
 
@@ -1201,7 +1199,8 @@ class ExtensionManagementUtilityTest extends UnitTestCase
             ->getMock();
         $mockCacheManager->expects($this->never())->method('getCache');
         ExtensionManagementUtilityAccessibleProxy::setCacheManager($mockCacheManager);
-        $GLOBALS['TYPO3_LOADED_EXT'] = new LoadedExtensionsArray($this->createMockPackageManagerWithMockPackage($this->getUniqueId()));
+        $packageManager = $this->createMockPackageManagerWithMockPackage($this->getUniqueId());
+        ExtensionManagementUtility::setPackageManager($packageManager);
         ExtensionManagementUtility::loadExtLocalconf(false);
     }
 
@@ -1241,7 +1240,7 @@ class ExtensionManagementUtilityTest extends UnitTestCase
         $packageManager = $this->createMockPackageManagerWithMockPackage($extensionName);
         $extLocalconfLocation = $packageManager->getPackage($extensionName)->getPackagePath() . 'ext_localconf.php';
         file_put_contents($extLocalconfLocation, "<?php\n\nthrow new RuntimeException('', 1340559079);\n\n?>");
-        $GLOBALS['TYPO3_LOADED_EXT'] = new LoadedExtensionsArray($packageManager);
+        ExtensionManagementUtility::setPackageManager($packageManager);
         ExtensionManagementUtilityAccessibleProxy::loadSingleExtLocalconfFiles();
     }
 
@@ -1333,7 +1332,7 @@ class ExtensionManagementUtilityTest extends UnitTestCase
         $extLocalconfLocation = $packageManager->getPackage($extensionName)->getPackagePath() . 'ext_localconf.php';
         $uniqueStringInLocalconf = $this->getUniqueId('foo');
         file_put_contents($extLocalconfLocation, "<?php\n\n" . $uniqueStringInLocalconf . "\n\n?>");
-        $GLOBALS['TYPO3_LOADED_EXT'] = new LoadedExtensionsArray($packageManager);
+        ExtensionManagementUtility::setPackageManager($packageManager);
         $mockCache = $this->getMockBuilder(PhpFrontend::class)
             ->setMethods(['getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag', 'require'])
             ->disableOriginalConstructor()
@@ -1356,7 +1355,7 @@ class ExtensionManagementUtilityTest extends UnitTestCase
     {
         $extensionName = $this->getUniqueId('foo');
         $packageManager = $this->createMockPackageManagerWithMockPackage($extensionName);
-        $GLOBALS['TYPO3_LOADED_EXT'] = new LoadedExtensionsArray($packageManager);
+        ExtensionManagementUtility::setPackageManager($packageManager);
         $mockCache = $this->getMockBuilder(PhpFrontend::class)
             ->setMethods(['getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag', 'require'])
             ->disableOriginalConstructor()
@@ -1391,7 +1390,8 @@ class ExtensionManagementUtilityTest extends UnitTestCase
         $mockCacheManager->expects($this->any())->method('getCache')->will($this->returnValue($mockCache));
         ExtensionManagementUtilityAccessibleProxy::setCacheManager($mockCacheManager);
         $mockCache->expects($this->once())->method('set')->with($this->anything(), $this->anything(), $this->equalTo([]));
-        $GLOBALS['TYPO3_LOADED_EXT'] = new LoadedExtensionsArray($this->createMockPackageManagerWithMockPackage($this->getUniqueId()));
+        $packageManager = $this->createMockPackageManagerWithMockPackage($this->getUniqueId());
+        ExtensionManagementUtility::setPackageManager($packageManager);
         ExtensionManagementUtilityAccessibleProxy::createExtLocalconfCacheEntry();
     }
 
@@ -1459,7 +1459,6 @@ class ExtensionManagementUtilityTest extends UnitTestCase
         GeneralUtility::mkdir($packagePath);
         GeneralUtility::mkdir($packagePath . 'Configuration/');
         GeneralUtility::mkdir($packagePath . 'Configuration/TCA/');
-        $GLOBALS['TYPO3_LOADED_EXT'] = new LoadedExtensionsArray($packageManager);
         ExtensionManagementUtility::setPackageManager($packageManager);
         $uniqueTableName = $this->getUniqueId('table_name_');
         $uniqueStringInTableConfiguration = $this->getUniqueId('table_configuration_');
@@ -1532,7 +1531,8 @@ class ExtensionManagementUtilityTest extends UnitTestCase
             ->getMock();
         $mockCacheManager->expects($this->never())->method('getCache');
         ExtensionManagementUtilityAccessibleProxy::setCacheManager($mockCacheManager);
-        $GLOBALS['TYPO3_LOADED_EXT'] = new LoadedExtensionsArray($this->createMockPackageManagerWithMockPackage($this->getUniqueId()));
+        $packageManager = $this->createMockPackageManagerWithMockPackage($this->getUniqueId());
+        ExtensionManagementUtility::setPackageManager($packageManager);
         ExtensionManagementUtility::loadExtLocalconf(false);
     }
 
@@ -1569,15 +1569,12 @@ class ExtensionManagementUtilityTest extends UnitTestCase
     public function createExtTablesCacheEntryWritesCacheEntryWithContentOfLoadedExtensionExtTables()
     {
         $extensionName = $this->getUniqueId('foo');
-        $extTablesLocation = Environment::getVarPath() . '/tests/' . $this->getUniqueId('test_ext_tables') . '.php';
-        $this->testFilesToDelete[] = $extTablesLocation;
+        $packageManager = $this->createMockPackageManagerWithMockPackage($extensionName);
+        $extensionPath = $packageManager->getPackage($extensionName)->getPackagePath();
+        $extTablesLocation = $extensionPath . 'ext_tables.php';
         $uniqueStringInTables = $this->getUniqueId('foo');
         file_put_contents($extTablesLocation, "<?php\n\n$uniqueStringInTables\n\n?>");
-        $GLOBALS['TYPO3_LOADED_EXT'] = [
-            $extensionName => [
-                'ext_tables.php' => $extTablesLocation
-            ]
-        ];
+        ExtensionManagementUtility::setPackageManager($packageManager);
         $mockCache = $this->getMockBuilder(PhpFrontend::class)
             ->setMethods(['getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag', 'require'])
             ->disableOriginalConstructor()
@@ -1599,9 +1596,8 @@ class ExtensionManagementUtilityTest extends UnitTestCase
     public function createExtTablesCacheEntryWritesCacheEntryWithExtensionContentOnlyIfExtTablesExists()
     {
         $extensionName = $this->getUniqueId('foo');
-        $GLOBALS['TYPO3_LOADED_EXT'] = [
-            $extensionName => [],
-        ];
+        $packageManager = $this->createMockPackageManagerWithMockPackage($extensionName);
+        ExtensionManagementUtility::setPackageManager($packageManager);
         $mockCache = $this->getMockBuilder(PhpFrontend::class)
             ->setMethods(['getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag', 'require'])
             ->disableOriginalConstructor()
@@ -1636,7 +1632,8 @@ class ExtensionManagementUtilityTest extends UnitTestCase
         $mockCacheManager->expects($this->any())->method('getCache')->will($this->returnValue($mockCache));
         ExtensionManagementUtilityAccessibleProxy::setCacheManager($mockCacheManager);
         $mockCache->expects($this->once())->method('set')->with($this->anything(), $this->anything(), $this->equalTo([]));
-        $GLOBALS['TYPO3_LOADED_EXT'] = new LoadedExtensionsArray($this->createMockPackageManagerWithMockPackage($this->getUniqueId()));
+        $packageManager = $this->createMockPackageManagerWithMockPackage($this->getUniqueId());
+        ExtensionManagementUtility::setPackageManager($packageManager);
         ExtensionManagementUtilityAccessibleProxy::createExtTablesCacheEntry();
     }
 
@@ -1828,13 +1825,11 @@ class ExtensionManagementUtilityTest extends UnitTestCase
     public function addPluginSetsTcaCorrectlyForGivenExtKeyAsParameter()
     {
         $extKey = 'indexed_search';
-        $GLOBALS['TYPO3_LOADED_EXT'] = [];
-        $GLOBALS['TYPO3_LOADED_EXT'][$extKey]['ext_icon'] = 'foo.gif';
         $expectedTCA = [
             [
                 'label',
                 $extKey,
-                'EXT:' . $extKey . '/foo.gif'
+                'EXT:' . $extKey . '/Resources/Public/Icons/Extension.png'
             ]
         ];
         $GLOBALS['TCA']['tt_content']['columns']['list_type']['config']['items'] = [];
index 8c1f49c..deb5b01 100644 (file)
@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Core\Tests\UnitDeprecated\TypoScript;
  */
 
 use TYPO3\CMS\Core\Context\Context;
+use TYPO3\CMS\Core\Package\PackageManager;
 use TYPO3\CMS\Core\TypoScript\TemplateService;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
@@ -35,7 +36,8 @@ class TemplateServiceTest extends UnitTestCase
      */
     protected function setUp(): void
     {
-        $this->templateService = new TemplateService(new Context());
+        $packageManagerProphecy = $this->prophesize(PackageManager::class);
+        $this->templateService = new TemplateService(new Context(), $packageManagerProphecy->reveal());
     }
 
     /**
index 29a9e9f..83df9be 100644 (file)
@@ -15,7 +15,6 @@ namespace TYPO3\CMS\Core\Tests\Unit\Utility;
  */
 
 use TYPO3\CMS\Core\Cache\CacheManager;
-use TYPO3\CMS\Core\Compatibility\LoadedExtensionsArray;
 use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Package\Package;
 use TYPO3\CMS\Core\Package\PackageManager;
@@ -50,7 +49,6 @@ class ExtensionManagementUtilityTest extends UnitTestCase
         ExtensionManagementUtility::clearExtensionKeyMap();
         ExtensionManagementUtilityAccessibleProxy::setPackageManager($this->backUpPackageManager);
         ExtensionManagementUtilityAccessibleProxy::setCacheManager(null);
-        $GLOBALS['TYPO3_LOADED_EXT'] = new LoadedExtensionsArray($this->backUpPackageManager);
         parent::tearDown();
     }
 
index 2235b34..339f7d6 100644 (file)
@@ -275,15 +275,13 @@ class ExtensionUtilityTest extends UnitTestCase
     public function registerPluginTriggersAddPluginWhichSetsPluginIconPathIfUsingUnderscoredExtensionNameAndIconPathNotGiven()
     {
         $GLOBALS['TCA']['tt_content']['columns']['list_type']['config']['items'] = [];
-        $GLOBALS['TYPO3_LOADED_EXT'] = [];
-        $GLOBALS['TYPO3_LOADED_EXT']['indexed_search']['ext_icon'] = 'foo.gif';
         ExtensionUtility::registerPlugin(
             'indexed_search',
             'Pi2',
             'Testing'
         );
         $this->assertEquals(
-            'EXT:indexed_search/foo.gif',
+            'EXT:indexed_search/Resources/Public/Icons/Extension.png',
             $GLOBALS['TCA']['tt_content']['columns']['list_type']['config']['items'][0][2]
         );
     }
@@ -297,15 +295,13 @@ class ExtensionUtilityTest extends UnitTestCase
     public function registerPluginTriggersAddPluginWhichSetsPluginIconPathIfUsingUpperCameCasedExtensionNameAndIconPathNotGiven()
     {
         $GLOBALS['TCA']['tt_content']['columns']['list_type']['config']['items'] = [];
-        $GLOBALS['TYPO3_LOADED_EXT'] = [];
-        $GLOBALS['TYPO3_LOADED_EXT']['indexed_search']['ext_icon'] = 'foo.gif';
         ExtensionUtility::registerPlugin(
             'IndexedSearch',
             'Pi2',
             'Testing'
         );
         $this->assertEquals(
-            'EXT:indexed_search/foo.gif',
+            'EXT:indexed_search/Resources/Public/Icons/Extension.png',
             $GLOBALS['TCA']['tt_content']['columns']['list_type']['config']['items'][0][2]
         );
     }
index 5878c4e..05fc3cd 100644 (file)
@@ -27,6 +27,7 @@ use TYPO3\CMS\Core\Core\ApplicationContext;
 use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\LinkHandling\LinkService;
 use TYPO3\CMS\Core\Log\Logger;
+use TYPO3\CMS\Core\Package\PackageManager;
 use TYPO3\CMS\Core\Resource\Exception\InvalidPathException;
 use TYPO3\CMS\Core\Resource\File;
 use TYPO3\CMS\Core\Resource\ResourceFactory;
@@ -126,8 +127,12 @@ class ContentObjectRendererTest extends UnitTestCase
     protected function setUp(): void
     {
         $GLOBALS['SIM_ACCESS_TIME'] = 1534278180;
+        $packageManagerMock = $this->getMockBuilder(PackageManager::class)
+            ->disableOriginalConstructor()
+            ->getMock();
         $this->templateServiceMock =
             $this->getMockBuilder(TemplateService::class)
+                ->setConstructorArgs([null, $packageManagerMock])
                 ->setMethods(['linkData'])
                 ->getMock();
         $pageRepositoryMock =
@@ -2750,7 +2755,11 @@ class ContentObjectRendererTest extends UnitTestCase
      */
     public function typolinkReturnsCorrectLinksForEmailsAndUrls($linkText, $configuration, $expectedResult): void
     {
+        $packageManagerMock = $this->getMockBuilder(PackageManager::class)
+            ->disableOriginalConstructor()
+            ->getMock();
         $templateServiceObjectMock = $this->getMockBuilder(TemplateService::class)
+            ->setConstructorArgs([null, $packageManagerMock])
             ->setMethods(['dummy'])
             ->getMock();
         $templateServiceObjectMock->setup = [
@@ -2995,7 +3004,11 @@ class ContentObjectRendererTest extends UnitTestCase
      */
     public function typolinkReturnsCorrectLinksFiles($linkText, $configuration, $expectedResult): void
     {
+        $packageManagerMock = $this->getMockBuilder(PackageManager::class)
+            ->disableOriginalConstructor()
+            ->getMock();
         $templateServiceObjectMock = $this->getMockBuilder(TemplateService::class)
+            ->setConstructorArgs([null, $packageManagerMock])
             ->setMethods(['dummy'])
             ->getMock();
         $templateServiceObjectMock->setup = [
@@ -3149,7 +3162,11 @@ class ContentObjectRendererTest extends UnitTestCase
         $absRefPrefix,
         $expectedResult
     ): void {
+        $packageManagerMock = $this->getMockBuilder(PackageManager::class)
+            ->disableOriginalConstructor()
+            ->getMock();
         $templateServiceObjectMock = $this->getMockBuilder(TemplateService::class)
+            ->setConstructorArgs([null, $packageManagerMock])
             ->setMethods(['dummy'])
             ->getMock();
         $templateServiceObjectMock->setup = [
index b5020d0..5d2faff 100644 (file)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Frontend\Tests\Unit\ContentObject;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Package\PackageManager;
 use TYPO3\CMS\Core\Resource\Collection\StaticFileCollection;
 use TYPO3\CMS\Core\Resource\File;
 use TYPO3\CMS\Core\Resource\FileCollectionRepository;
@@ -51,7 +52,11 @@ class FilesContentObjectTest extends UnitTestCase
     protected function setUp()
     {
         $GLOBALS['SIM_ACCESS_TIME'] = 0;
+        $packageManagerMock = $this->getMockBuilder(PackageManager::class)
+            ->disableOriginalConstructor()
+            ->getMock();
         $templateService = $this->getMockBuilder(TemplateService::class)
+            ->setConstructorArgs([null, $packageManagerMock])
             ->setMethods(['getFileName', 'linkData'])
             ->getMock();
         $tsfe = $this->getMockBuilder(TypoScriptFrontendController::class)
index 5b2ef04..e61cbe9 100644 (file)
@@ -30,6 +30,8 @@ use TYPO3\CMS\Core\Http\JsonResponse;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\Messaging\FlashMessageQueue;
 use TYPO3\CMS\Core\Migrations\TcaMigration;
+use TYPO3\CMS\Core\Package\Package;
+use TYPO3\CMS\Core\Package\PackageManager;
 use TYPO3\CMS\Core\Registry;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -77,6 +79,19 @@ class UpgradeController extends AbstractController
     protected $coreVersionService;
 
     /**
+     * @var PackageManager
+     */
+    protected $packageManager;
+
+    /**
+     * @param PackageManager|null $packageManager
+     */
+    public function __construct(PackageManager $packageManager = null)
+    {
+        $this->packageManager = $packageManager ?? GeneralUtility::makeInstance(PackageManager::class);
+    }
+
+    /**
      * Matcher registry of extension scanner.
      * Node visitors that implement CodeScannerInterface
      *
@@ -369,7 +384,7 @@ class UpgradeController extends AbstractController
 
         return new JsonResponse([
             'success' => true,
-            'extensions' => array_keys($GLOBALS['TYPO3_LOADED_EXT']),
+            'extensions' => array_keys($this->packageManager->getActivePackages()),
             'html' => $view->render(),
         ]);
     }
@@ -383,9 +398,9 @@ class UpgradeController extends AbstractController
     public function extensionCompatTesterLoadExtLocalconfAction(ServerRequestInterface $request): ResponseInterface
     {
         $extension = $request->getParsedBody()['install']['extension'];
-        foreach ($GLOBALS['TYPO3_LOADED_EXT'] as $extKey => $extDetails) {
-            $this->extensionCompatTesterLoadExtLocalconfForExtension($extKey, $extDetails);
-            if ($extKey === $extension) {
+        foreach ($this->packageManager->getActivePackages() as $package) {
+            $this->extensionCompatTesterLoadExtLocalconfForExtension($package);
+            if ($package->getPackageKey() === $extension) {
                 break;
             }
         }
@@ -403,13 +418,14 @@ class UpgradeController extends AbstractController
     public function extensionCompatTesterLoadExtTablesAction(ServerRequestInterface $request): ResponseInterface
     {
         $extension = $request->getParsedBody()['install']['extension'];
-        foreach ($GLOBALS['TYPO3_LOADED_EXT'] as $extKey => $extDetails) {
+        $activePackages = $this->packageManager->getActivePackages();
+        foreach ($activePackages as $package) {
             // Load all ext_localconf files first
-            $this->extensionCompatTesterLoadExtLocalconfForExtension($extKey, $extDetails);
+            $this->extensionCompatTesterLoadExtLocalconfForExtension($package);
         }
-        foreach ($GLOBALS['TYPO3_LOADED_EXT'] as $extKey => $extDetails) {
-            $this->extensionCompatTesterLoadExtTablesForExtension($extKey, $extDetails);
-            if ($extKey === $extension) {
+        foreach ($activePackages as $package) {
+            $this->extensionCompatTesterLoadExtTablesForExtension($package);
+            if ($package->getPackageKey() === $extension) {
                 break;
             }
         }
@@ -699,10 +715,10 @@ class UpgradeController extends AbstractController
         $loadTcaService = GeneralUtility::makeInstance(LoadTcaService::class);
         $loadTcaService->loadExtensionTablesWithoutMigration();
         $baseTca = $GLOBALS['TCA'];
-        foreach ($GLOBALS['TYPO3_LOADED_EXT'] as $extensionKey => $extensionInformation) {
-            if ((is_array($extensionInformation) || $extensionInformation instanceof \ArrayAccess)
-                && $extensionInformation['ext_tables.php']
-            ) {
+        foreach ($this->packageManager->getActivePackages() as $package) {
+            $extensionKey = $package->getPackageKey();
+            $extTablesPath = $package->getPackagePath() . 'ext_tables.php';
+            if (@file_exists($extTablesPath)) {
                 $loadTcaService->loadSingleExtTablesFile($extensionKey);
                 $newTca = $GLOBALS['TCA'];
                 if ($newTca !== $baseTca) {
@@ -1091,22 +1107,22 @@ class UpgradeController extends AbstractController
      * Loads ext_localconf.php for a single extension. Method is a modified copy of
      * the original bootstrap method.
      *
-     * @param string $extensionKey
-     * @param array $extension
+     * @param Package $package
      */
-    protected function extensionCompatTesterLoadExtLocalconfForExtension($extensionKey, array $extension)
+    protected function extensionCompatTesterLoadExtLocalconfForExtension(Package $package)
     {
+        $extLocalconfPath = $package->getPackagePath() . 'ext_localconf.php';
         // This is the main array meant to be manipulated in the ext_localconf.php files
         // In general it is recommended to not rely on it to be globally defined in that
         // scope but to use $GLOBALS['TYPO3_CONF_VARS'] instead.
         // Nevertheless we define it here as global for backwards compatibility.
         global $TYPO3_CONF_VARS;
-        $_EXTKEY = $extensionKey;
-        if (isset($extension['ext_localconf.php']) && $extension['ext_localconf.php']) {
+        if (@file_exists($extLocalconfPath)) {
             // $_EXTKEY and $_EXTCONF are available in ext_localconf.php
             // and are explicitly set in cached file as well
+            $_EXTKEY = $package->getPackageKey();
             $_EXTCONF = $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$_EXTKEY] ?? null;
-            require $extension['ext_localconf.php'];
+            require $extLocalconfPath;
         }
     }
 
@@ -1114,11 +1130,11 @@ class UpgradeController extends AbstractController
      * Loads ext_tables.php for a single extension. Method is a modified copy of
      * the original bootstrap method.
      *
-     * @param string $extensionKey
-     * @param array $extension
+     * @param Package $package
      */
-    protected function extensionCompatTesterLoadExtTablesForExtension($extensionKey, array $extension)
+    protected function extensionCompatTesterLoadExtTablesForExtension(Package $package)
     {
+        $extTablesPath = $package->getPackagePath() . 'ext_tables.php';
         // In general it is recommended to not rely on it to be globally defined in that
         // scope, but we can not prohibit this without breaking backwards compatibility
         global $T3_SERVICES, $T3_VAR, $TYPO3_CONF_VARS;
@@ -1127,11 +1143,11 @@ class UpgradeController extends AbstractController
         global $_EXTKEY;
         // Load each ext_tables.php file of loaded extensions
         $_EXTKEY = $extensionKey;
-        if (isset($extension['ext_tables.php']) && $extension['ext_tables.php']) {
+        if (@file_exists($extTablesPath)) {
             // $_EXTKEY and $_EXTCONF are available in ext_tables.php
             // and are explicitly set in cached file as well
             $_EXTCONF = $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$_EXTKEY] ?? null;
-            require $extension['ext_tables.php'];
+            require $extTablesPath;
         }
     }
 
index 37ebe8a..b01684a 100644 (file)
@@ -93,21 +93,22 @@ class LoadTcaService
         global $PAGES_TYPES, $TBE_STYLES;
         global $_EXTKEY;
 
-        if (!isset($GLOBALS['TYPO3_LOADED_EXT'][$extensionKey])) {
+        $packageManager = GeneralUtility::makeInstance(PackageManager::class);
+        try {
+            $package = $packageManager->getPackage($extensionKey);
+        } catch (\TYPO3\CMS\Core\Package\Exception\UnknownPackageException $e) {
             throw new \RuntimeException(
-                'Extension ' . $extensionKey . ' does not exist in TYPO3_LOADED_EXT',
+                'Extension ' . $extensionKey . ' is not active',
                 1477217619
             );
         }
 
-        $extensionInformation = $GLOBALS['TYPO3_LOADED_EXT'][$extensionKey];
-        $_EXTKEY = $extensionKey;
-        // Load each ext_tables.php file of loaded extensions
-        if ((is_array($extensionInformation) || $extensionInformation instanceof \ArrayAccess)
-            && $extensionInformation['ext_tables.php']
-        ) {
+        $extTablesPath = $package->getPackagePath() . 'ext_tables.php';
+        // Load ext_tables.php file of the extension
+        if (@file_exists($extTablesPath)) {
             // $_EXTKEY and $_EXTCONF are available in ext_tables.php
             // and are explicitly set in cached file as well
+            $_EXTKEY = $extensionKey;
             $_EXTCONF = $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$_EXTKEY] ?? null;
             require $extensionInformation['ext_tables.php'];
         }
index 85f49df..c6b35df 100644 (file)
@@ -20,4 +20,9 @@ return [
             'Deprecation-83736-DeprecatedGlobalsTYPO3_REQUEST.rst',
         ],
     ],
+    '$GLOBALS[\'TYPO3_LOADED_EXT\']' => [
+        'restFiles' => [
+            'Deprecation-86404-DeprecateGLOBALSTYPO3_LOADED_EXT.rst',
+        ],
+    ],
 ];
index 25cc83e..5152116 100644 (file)
@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Install\Tests\Unit\Controller;
  */
 
 use Psr\Http\Message\ServerRequestInterface;
+use TYPO3\CMS\Core\Package\PackageManager;
 use TYPO3\CMS\Fluid\View\StandaloneView;
 use TYPO3\CMS\Install\Controller\UpgradeController;
 
@@ -69,8 +70,12 @@ class UpgradeControllerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCa
             ],
         ]);
 
+        $packageManagerMock = $this->getMockBuilder(PackageManager::class)
+            ->disableOriginalConstructor()
+            ->getMock();
         /** @var UpgradeController|\PHPUnit\Framework\MockObject\MockObject $subject */
         $subject = $this->getMockBuilder(UpgradeController::class)
+            ->setConstructorArgs([$packageManagerMock])
             ->setMethods(['getDocumentationFiles', 'initializeStandaloneView'])
             ->getMock();
 
index 9f167a7..c393767 100644 (file)
@@ -61,6 +61,7 @@ class ConfigurationController
             'type' => 'global',
             'globalKey' => 'TCA_DESCR',
         ],
+        // @deprecated will be removed in v10
         'loadedExt' => [
             'label' => 'loadedExt',
             'type' => 'global',