[!!!][TASK] Do not rely on global variables for ext_*.php files 00/59300/7
authorBenni Mack <benni@typo3.org>
Thu, 27 Dec 2018 19:13:50 +0000 (20:13 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Fri, 18 Jan 2019 14:04:26 +0000 (15:04 +0100)
ext_tables.php, ext_localconf.php and all Configuration/TCA/*.php
do not have global scope anymore.

Thus, it is necessary to use
$GLOBALS['TYPO3_CONF_VARS'] instead of $TYPO3_CONF_VARS

Also, $_EXTKEY and $_EXTCONF are gone in these files.

Resolves: #87483
Releases: master
Change-Id: I2c33c696151ace8596cbc9a59a43ef188de26b9c
Reviewed-on: https://review.typo3.org/59300
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: TYPO3com <noreply@typo3.com>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/backend/Classes/Template/DocumentTemplate.php
typo3/sysext/core/Classes/Utility/ExtensionManagementUtility.php
typo3/sysext/core/Documentation/Changelog/master/Breaking-87193-DeprecatedFunctionalityRemoved.rst
typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/blog_example/ext_tables.php
typo3/sysext/install/Classes/Controller/UpgradeController.php
typo3/sysext/install/Classes/Service/LoadTcaService.php
typo3/sysext/scheduler/Documentation/DevelopersGuide/CreatingTasks/Index.rst
typo3/sysext/t3editor/Resources/Private/tsref.xml

index 6c389b3..8558ddd 100644 (file)
@@ -642,7 +642,7 @@ function jumpToUrl(URL) {
             foreach ($GLOBALS['TBE_STYLES']['skins'] as $skinExtKey => $skin) {
                 $skinStylesheetDirs = $this->stylesheetsSkins;
                 // Skins can add custom stylesheetDirectories using
-                // $GLOBALS['TBE_STYLES']['skins'][$_EXTKEY]['stylesheetDirectories']
+                // $GLOBALS['TBE_STYLES']['skins']['your_extension_key']['stylesheetDirectories']
                 if (is_array($skin['stylesheetDirectories'])) {
                     $skinStylesheetDirs = array_merge($skinStylesheetDirs, $skin['stylesheetDirectories']);
                 }
index aaa64a6..09fe3d7 100644 (file)
@@ -1443,18 +1443,9 @@ tt_content.' . $key . $suffix . ' {
      */
     protected static function loadSingleExtLocalconfFiles()
     {
-        // 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;
         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 $extLocalconfPath;
             }
         }
@@ -1473,8 +1464,6 @@ tt_content.' . $key . $suffix . ' {
         $phpCodeToCache[] = ' * Compiled ext_localconf.php cache file';
         $phpCodeToCache[] = ' */';
         $phpCodeToCache[] = '';
-        $phpCodeToCache[] = 'global $TYPO3_CONF_VARS, $T3_SERVICES, $T3_VAR;';
-        $phpCodeToCache[] = '';
         // Iterate through loaded extensions and add ext_localconf content
         foreach (static::$packageManager->getActivePackages() as $package) {
             $extensionKey = $package->getPackageKey();
@@ -1486,10 +1475,6 @@ tt_content.' . $key . $suffix . ' {
                 $phpCodeToCache[] = ' * File: ' . $extLocalconfPath;
                 $phpCodeToCache[] = ' */';
                 $phpCodeToCache[] = '';
-                // Set $_EXTKEY and $_EXTCONF for this extension
-                $phpCodeToCache[] = '$_EXTKEY = \'' . $extensionKey . '\';';
-                $phpCodeToCache[] = '$_EXTCONF = $GLOBALS[\'TYPO3_CONF_VARS\'][\'EXT\'][\'extConf\'][$_EXTKEY] ?? null;';
-                $phpCodeToCache[] = '';
                 // Add ext_localconf.php content of extension
                 $phpCodeToCache[] = trim(file_get_contents($extLocalconfPath));
                 $phpCodeToCache[] = '';
@@ -1691,20 +1676,10 @@ tt_content.' . $key . $suffix . ' {
      */
     protected static function loadSingleExtTablesFiles()
     {
-        // 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;
-        global $TBE_MODULES, $TBE_MODULES_EXT, $TCA;
-        global $PAGES_TYPES, $TBE_STYLES;
-        global $_EXTKEY;
         // Load each ext_tables.php file of loaded extensions
         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 $extTablesPath;
             }
         }
@@ -1721,11 +1696,6 @@ tt_content.' . $key . $suffix . ' {
         $phpCodeToCache[] = ' * Compiled ext_tables.php cache file';
         $phpCodeToCache[] = ' */';
         $phpCodeToCache[] = '';
-        $phpCodeToCache[] = 'global $T3_SERVICES, $T3_VAR, $TYPO3_CONF_VARS;';
-        $phpCodeToCache[] = 'global $TBE_MODULES, $TBE_MODULES_EXT, $TCA;';
-        $phpCodeToCache[] = 'global $PAGES_TYPES, $TBE_STYLES;';
-        $phpCodeToCache[] = 'global $_EXTKEY;';
-        $phpCodeToCache[] = '';
         // Iterate through loaded extensions and add ext_tables content
         foreach (static::$packageManager->getActivePackages() as $package) {
             $extensionKey = $package->getPackageKey();
@@ -1737,10 +1707,6 @@ tt_content.' . $key . $suffix . ' {
                 $phpCodeToCache[] = ' * File: ' . $extTablesPath;
                 $phpCodeToCache[] = ' */';
                 $phpCodeToCache[] = '';
-                // Set $_EXTKEY and $_EXTCONF for this extension
-                $phpCodeToCache[] = '$_EXTKEY = \'' . $extensionKey . '\';';
-                $phpCodeToCache[] = '$_EXTCONF = $GLOBALS[\'TYPO3_CONF_VARS\'][\'EXT\'][\'extConf\'][$_EXTKEY] ?? null;';
-                $phpCodeToCache[] = '';
                 // Add ext_tables.php content of extension
                 $phpCodeToCache[] = trim(file_get_contents($extTablesPath));
                 $phpCodeToCache[] = '';
index e32f5f7..de758c5 100644 (file)
@@ -1333,6 +1333,9 @@ The following features have been removed:
 * The array key :php:`uploadfolder` in extensions :php:`ext_emconf.php` files is obsolete and ignored.
 * Standalone install tool entry point :file:`typo3/install/index.php` has been dropped, use :file:`typo3/install.php` instead
 * INCLUDE_TYPOSCRIPT statements in typoscript using a `.txt` ending for a file that ends with `.typoscript` does not work any longer
+* These variables are no longer declared in :file:`ext_tables.php` and :file:`ext_localconf.php` files: :php:`$_EXTKEY`, :php:`$_EXTCONF`,
+  :php:`T3_SERVICES`, :php:`T3_VAR`, :php:`TYPO3_CONF_VARS`, :php:`TBE_MODULES`, :php:`TBE_MODULES_EXT`, :php:`TCA`,
+  :php:`PAGES_TYPES`, :php:`TBE_STYLES`
 
 
 The following database tables have been removed:
index dd234d1..6698e39 100644 (file)
@@ -4,10 +4,10 @@ defined('TYPO3_MODE') or die();
 /**
  * Add labels for context sensitive help (CSH)
  */
-\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr('_MOD_web_BlogExampleTxBlogexampleM1', 'EXT:' . $_EXTKEY . '/Resources/Private/Language/locallang_csh.xml');
+\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr('_MOD_web_BlogExampleTxBlogexampleM1', 'EXT:blog_example/Resources/Private/Language/locallang_csh.xml');
 
-\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin($_EXTKEY, 'Blogs', 'Blog listing');
+\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin('blog_example', 'Blogs', 'Blog listing');
 
 // Categorize Blog,Post records
-\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::makeCategorizable($_EXTKEY, 'tx_blogexample_domain_model_blog');
-\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::makeCategorizable($_EXTKEY, 'tx_blogexample_domain_model_post');
+\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::makeCategorizable('blog_example', 'tx_blogexample_domain_model_blog');
+\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::makeCategorizable('blog_example', 'tx_blogexample_domain_model_post');
index b295f73..94d9e27 100644 (file)
@@ -1099,16 +1099,7 @@ class UpgradeController extends AbstractController
     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;
         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 $extLocalconfPath;
         }
     }
@@ -1122,18 +1113,7 @@ class UpgradeController extends AbstractController
     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;
-        global $TBE_MODULES, $TBE_MODULES_EXT, $TCA;
-        global $PAGES_TYPES, $TBE_STYLES;
-        global $_EXTKEY;
-        // Load each ext_tables.php file of loaded extensions
-        $_EXTKEY = $package->getPackageKey();
         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 $extTablesPath;
         }
     }
index 420f095..8c07844 100644 (file)
@@ -89,11 +89,6 @@ class LoadTcaService
      */
     public function loadSingleExtTablesFile(string $extensionKey)
     {
-        global $T3_SERVICES, $T3_VAR, $TYPO3_CONF_VARS;
-        global $TBE_MODULES, $TBE_MODULES_EXT, $TCA;
-        global $PAGES_TYPES, $TBE_STYLES;
-        global $_EXTKEY;
-
         $packageManager = GeneralUtility::makeInstance(PackageManager::class);
         try {
             $package = $packageManager->getPackage($extensionKey);
@@ -107,10 +102,6 @@ class LoadTcaService
         $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 $extTablesPath;
         }
     }
index fec93b4..73be3af 100644 (file)
@@ -275,9 +275,9 @@ task. Let's look at one of the base classes declaration as an example:
 
        // Add caching framework garbage collection task
        $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][\TYPO3\CMS\Scheduler\Task\CachingFrameworkGarbageCollectionTask::class] = array(
-               'extension' => $_EXTKEY,
-               'title' => 'LLL:EXT:' . $_EXTKEY . '/locallang.xlf:cachingFrameworkGarbageCollection.name',
-               'description' => 'LLL:EXT:' . $_EXTKEY . '/locallang.xlf:cachingFrameworkGarbageCollection.description',
+               'extension' => 'your_extension_key,
+               'title' => 'LLL:EXT:your_extension_key/locallang.xlf:cachingFrameworkGarbageCollection.name',
+               'description' => 'LLL:EXT:your_extension_key/locallang.xlf:cachingFrameworkGarbageCollection.description',
                'additionalFields' => \TYPO3\CMS\Scheduler\Task\CachingFrameworkGarbageCollectionAdditionalFieldProvider::class
        );
 
index 0c6dfd8..0672d33 100644 (file)
@@ -679,7 +679,7 @@ Note: TYPO3 comes with a built-in concatenation handler, but you can also regist
 
 Example:
 
-$GLOBALS['TYPO3_CONF_VARS']['FE']['jsConcatenateHandler'] = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'Classes/class.tx_myext_jsConcatenateHandler.php:tx_myext_jsConcatenateHandler->concatenateJs';]]></description>
+$GLOBALS['TYPO3_CONF_VARS']['FE']['jsConcatenateHandler'] = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('myext') . 'Classes/class.tx_myext_jsConcatenateHandler.php:tx_myext_jsConcatenateHandler->concatenateJs';]]></description>
                        <default><![CDATA[false]]></default>
                </property>
                <property name="concatenateCss" type="boolean">
@@ -693,7 +693,7 @@ Note: TYPO3 comes with a built-in concatenation handler, but you can also regist
 
 Example:
 
-$GLOBALS['TYPO3_CONF_VARS']['FE']['cssConcatenateHandler'] = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'Classes/class.tx_myext_cssConcatenateHandler.php:tx_myext_cssConcatenateHandler->concatenateCss';]]></description>
+$GLOBALS['TYPO3_CONF_VARS']['FE']['cssConcatenateHandler'] = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('myext') . 'Classes/class.tx_myext_cssConcatenateHandler.php:tx_myext_cssConcatenateHandler->concatenateCss';]]></description>
                        <default><![CDATA[false]]></default>
                </property>
                <property name="sendCacheHeaders" type="boolean">