From 6541b3eb425bcf6ebe26c2d2c9eb5ceb230991f7 Mon Sep 17 00:00:00 2001
From: Benni Mack <benni@typo3.org>
Date: Mon, 6 Apr 2020 11:52:35 +0200
Subject: [PATCH] [TASK] Deprecate runtime activated packages
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The option to register packages during runtime was a work-around
to dynamically modify the "extList". Using this feature has certain limitations:

* Runtime-activated Extensions cannot add their DI configuration
* Runtime-activated Extensions make every (!) single TYPO3 request much slower
  just like back in 6.2.0 times

The usecases from people using this functionality was to enable e.g. extensions
such as "devlog", "mask"/"mask_export" or "extensionbuilder" only on development
systems.

Nowadays, it is recommended - if this functionality is needed - to use TYPO3
Console and Composer Mode (with require-dev) to achieve a similar behaviour.

This also ensures a clear state of available extensions, and to build a proper
class map / autoloading mechansims of extensions in use.

Runtime-activated extensions also prohibit to continue to work on
a smoother integration between composer-mode and non-composer mode
in the future.

Resolves: #91030
Releases: master
Change-Id: If4344cd081e8f60f30c9a0fb4d0cb9c308bbfb66
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/64166
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Helmut Hummel <typo3@helhum.io>
Tested-by: Christian Eßl <indy.essl@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Helmut Hummel <typo3@helhum.io>
Reviewed-by: Josef Glatz <josefglatz@gmail.com>
Reviewed-by: Christian Eßl <indy.essl@gmail.com>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
---
 typo3/sysext/core/Classes/Core/Bootstrap.php  |  1 +
 .../core/Classes/Package/PackageManager.php   |  2 +
 ...cation-91030-Runtime-ActivatedPackages.rst | 47 +++++++++++++++++++
 .../Php/ArrayDimensionMatcher.php             |  5 ++
 4 files changed, 55 insertions(+)
 create mode 100644 typo3/sysext/core/Documentation/Changelog/master/Deprecation-91030-Runtime-ActivatedPackages.rst

diff --git a/typo3/sysext/core/Classes/Core/Bootstrap.php b/typo3/sysext/core/Classes/Core/Bootstrap.php
index 5b05d04a70cd..a8804d3bbd40 100644
--- a/typo3/sysext/core/Classes/Core/Bootstrap.php
+++ b/typo3/sysext/core/Classes/Core/Bootstrap.php
@@ -257,6 +257,7 @@ class Bootstrap
     {
         $packages = $GLOBALS['TYPO3_CONF_VARS']['EXT']['runtimeActivatedPackages'] ?? [];
         if (!empty($packages)) {
+            trigger_error('Support for runtime activated packages will be removed in TYPO3 v11.0.', E_USER_DEPRECATED);
             foreach ($packages as $runtimeAddedPackageKey) {
                 $packageManager->activatePackageDuringRuntime($runtimeAddedPackageKey);
             }
diff --git a/typo3/sysext/core/Classes/Package/PackageManager.php b/typo3/sysext/core/Classes/Package/PackageManager.php
index 72c0fdb665a1..bbfc1d9c7c7b 100644
--- a/typo3/sysext/core/Classes/Package/PackageManager.php
+++ b/typo3/sysext/core/Classes/Package/PackageManager.php
@@ -317,6 +317,7 @@ class PackageManager implements SingletonInterface
      *
      * @param string $packageKey
      * @return PackageInterface
+     * @deprecated will be removed in TYPO3 v11.0
      */
     protected function registerPackageDuringRuntime($packageKey)
     {
@@ -576,6 +577,7 @@ class PackageManager implements SingletonInterface
      * Enables packages during runtime, but no class aliases will be available
      *
      * @param string $packageKey
+     * @deprecated will be removed in TYPO3 v11.0
      */
     public function activatePackageDuringRuntime($packageKey)
     {
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-91030-Runtime-ActivatedPackages.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-91030-Runtime-ActivatedPackages.rst
new file mode 100644
index 000000000000..7eaf2428af56
--- /dev/null
+++ b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-91030-Runtime-ActivatedPackages.rst
@@ -0,0 +1,47 @@
+.. include:: ../../Includes.txt
+
+================================================
+Deprecation: #91030 - Runtime-Activated Packages
+================================================
+
+See :issue:`91030`
+
+Description
+===========
+
+TYPO3's global configuration option :php:`$GLOBALS['TYPO3_CONF_VARS']['EXT']['runtimeActivatedPackages']` has been deprecated.
+
+The option to register packages during runtime was introduced as
+a work-around to dynamically modify the "extension list" when migrating from TYPO3 v4.5 to TYPO3 v6.x.
+
+However, using this feature has certain limitations:
+
+* Runtime-activated Extensions cannot add their DI configuration
+* Runtime-activated Extensions make every (!) single TYPO3 request much slower just like back in 6.2.0 times
+
+The main usecase we know from people was to this functionality to enable e.g. extensions such as "devlog", "mask"/"mask_export" or "extensionbuilder" only on development systems.
+
+
+Impact
+======
+
+Having a TYPO3 system using Runtime Activated Packages functionality
+will trigger a PHP deprecation warning on every TYPO3 request.
+
+
+Affected Installations
+======================
+
+TYPO3 installations having the affected option set in either :php:`typo3conf/LocalConfiguration.php` or :php:`typo3conf/AdditionalConfiguration.php`.
+
+
+Migration
+=========
+
+It is recommended - if this functionality is needed - to use TYPO3
+Console and Composer Mode (with require-dev) to achieve a similar behavior.
+
+If it is critical to have such features, consider modifying the extension in question to deal with TYPO3's Context
+feature to enable / disable functionality for Production environment.
+
+.. index:: LocalConfiguration, FullyScanned, ext:core
\ No newline at end of file
diff --git a/typo3/sysext/install/Configuration/ExtensionScanner/Php/ArrayDimensionMatcher.php b/typo3/sysext/install/Configuration/ExtensionScanner/Php/ArrayDimensionMatcher.php
index e251614254c7..5a847da9235a 100644
--- a/typo3/sysext/install/Configuration/ExtensionScanner/Php/ArrayDimensionMatcher.php
+++ b/typo3/sysext/install/Configuration/ExtensionScanner/Php/ArrayDimensionMatcher.php
@@ -417,4 +417,9 @@ return [
             'Deprecation-91012-VariousHooksRelatedToTypoScriptFrontendController.rst',
         ],
     ],
+    '$GLOBALS[\'TYPO3_CONF_VARS\'][\'EXT\'][\'runtimeActivatedPackages\']' => [
+        'restFiles' => [
+            'Deprecation-91030-Runtime-ActivatedPackages.rst',
+        ],
+    ],
 ];
-- 
GitLab