From a5e3c21b848af4ae07089166fae6ed9aa3d53814 Mon Sep 17 00:00:00 2001
From: Wouter Wolters <typo3@wouterwolters.nl>
Date: Fri, 13 Aug 2021 12:36:13 +0200
Subject: [PATCH] [TASK] Use global namespace when concatenating
 ext_(localconf/tables)

With using a global namespace the usage of use statements
is not a problem anymore.

Resolves: #94280
Releases: master
Change-Id: I642b47b4257c22fa59a812763e5f92d5a0d2236a
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/70548
Tested-by: core-ci <typo3@b13.com>
Tested-by: Oliver Bartsch <bo@cedev.de>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Oliver Bartsch <bo@cedev.de>
Reviewed-by: crell <larry@garfieldtech.com>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
---
 .../core/Classes/Utility/ExtensionManagementUtility.php      | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/typo3/sysext/core/Classes/Utility/ExtensionManagementUtility.php b/typo3/sysext/core/Classes/Utility/ExtensionManagementUtility.php
index 18e3382d3fa5..0392b33073a9 100644
--- a/typo3/sysext/core/Classes/Utility/ExtensionManagementUtility.php
+++ b/typo3/sysext/core/Classes/Utility/ExtensionManagementUtility.php
@@ -1540,7 +1540,9 @@ tt_content.' . $key . $suffix . ' {
                 $phpCodeToCache[] = ' */';
                 $phpCodeToCache[] = '';
                 // Add ext_localconf.php content of extension
+                $phpCodeToCache[] = 'namespace {';
                 $phpCodeToCache[] = trim((string)file_get_contents($extLocalconfPath));
+                $phpCodeToCache[] = '}';
                 $phpCodeToCache[] = '';
                 $phpCodeToCache[] = '';
             }
@@ -1768,13 +1770,16 @@ tt_content.' . $key . $suffix . ' {
                 $phpCodeToCache[] = ' */';
                 $phpCodeToCache[] = '';
                 // Add ext_tables.php content of extension
+                $phpCodeToCache[] = 'namespace {';
                 $phpCodeToCache[] = trim((string)file_get_contents($extTablesPath));
+                $phpCodeToCache[] = '}';
                 $phpCodeToCache[] = '';
             }
         }
         $phpCodeToCache = implode(LF, $phpCodeToCache);
         // Remove all start and ending php tags from content
         $phpCodeToCache = preg_replace('/<\\?php|\\?>/is', '', $phpCodeToCache);
+        $phpCodeToCache = preg_replace('/declare\\s?+\\(\\s?+strict_types\\s?+=\\s?+1\\s?+\\);/is', '', (string)$phpCodeToCache);
         self::getCacheManager()->getCache('core')->set(self::getExtTablesCacheIdentifier(), $phpCodeToCache);
     }
 
-- 
GitLab