[!!!][TASK] Remove last usages of $GLOBALS[T3_VAR] 97/61197/3
authorBenni Mack <benni@typo3.org>
Mon, 1 Jul 2019 05:57:19 +0000 (07:57 +0200)
committerBenni Mack <benni@typo3.org>
Thu, 11 Jul 2019 12:22:23 +0000 (14:22 +0200)
The global state array "T3_VAR" for keeping some legacy
functionality has been removed.

It is not in used by TYPO3 Core anymore, the last occurrence
for "injecting" some data into Indexed Search indexing
has been removed, as SingletonInterface, hooks and the possibility
to provide ones' own indexer for custom download extensions
should be used instead.

Resolves: #88660
Releases: master
Change-Id: I5a587271983c6bb4ae6709c0140e818c4c1eb572
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/61197
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Steffen Frese <steffenf14@gmail.com>
Tested-by: Jörg Bösche <typo3@joergboesche.de>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Steffen Frese <steffenf14@gmail.com>
Reviewed-by: Jörg Bösche <typo3@joergboesche.de>
Reviewed-by: Benni Mack <benni@typo3.org>
typo3/sysext/core/Classes/Core/SystemEnvironmentBuilder.php
typo3/sysext/core/Documentation/Changelog/master/Breaking-88660-GLOBALST3_VARRemoved.rst [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Core/SystemEnvironmentBuilderTest.php
typo3/sysext/indexed_search/Classes/Indexer.php
typo3/sysext/indexed_search/Tests/Unit/IndexerTest.php
typo3/sysext/install/Configuration/ExtensionScanner/Php/ArrayDimensionMatcher.php
typo3/sysext/install/Configuration/ExtensionScanner/Php/ArrayGlobalMatcher.php

index 1d0f1fd..90cbeea 100644 (file)
@@ -207,7 +207,6 @@ class SystemEnvironmentBuilder
     protected static function initializeGlobalVariables()
     {
         // Unset variable(s) in global scope (security issue #13959)
-        $GLOBALS['T3_VAR'] = [];
         $GLOBALS['T3_SERVICES'] = [];
     }
 
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Breaking-88660-GLOBALST3_VARRemoved.rst b/typo3/sysext/core/Documentation/Changelog/master/Breaking-88660-GLOBALST3_VARRemoved.rst
new file mode 100644 (file)
index 0000000..abafa74
--- /dev/null
@@ -0,0 +1,50 @@
+.. include:: ../../Includes.txt
+
+===========================================
+Breaking: #88660 - $GLOBALS[T3_VAR] removed
+===========================================
+
+See :issue:`88660`
+
+Description
+===========
+
+The global variable :php:`$GLOBALS['T3_VAR']` previously used to hold global state for special
+use cases - previously used within Service API via :php:`GeneralUtility::makeInstanceService()`
+and to magically inject special hard-coded local indexed search files, has been removed.
+
+The overall goal of TYPO3's application is to not keep any state within global variables, and
+the `T3_VAR` ("TYPO3 Various") has not been actively used for that anymore since TYPO3 6.0, and
+has been kept only for backwards-compatibility of the existing solutions.
+
+The initialization of the global variable during TYPO3 Bootstrap, any usages of `T3_VAR`,
+especially within "indexed search" has been removed.
+
+
+Impact
+======
+
+Accessing :php:`$GLOBALS['T3_VAR']` is fully custom and not evaluated by TYPO3 Core anymore.
+
+Using the variable to modify any global state for e.g. Indexed Search's indexer via
+:php:`$GLOBALS['T3_VAR']['ext']['indexed_search']['indexLocalFiles']` is not respected anymore
+and has no effect.
+
+
+Affected Installations
+======================
+
+TYPO3 installations with third-party extensions or code within `AdditionalConfiguration.php`
+that actively set or read values from the global variable.
+
+
+Migration
+=========
+
+Use your own custom global namespace to identify that your specific extension code has nothing
+to do with TYPO3's legacy work.
+
+Use specific hooks for indexing local files used by download extensions in conjunction with
+Indexed Search.
+
+.. index:: PHP-API, FullyScanned, ext:indexed_search
\ No newline at end of file
index d78e448..1232477 100644 (file)
@@ -111,16 +111,6 @@ class SystemEnvironmentBuilderTest extends UnitTestCase
     /**
      * @test
      */
-    public function initializeGlobalVariablesSetsGlobalT3VarArray()
-    {
-        unset($GLOBALS['T3_VAR']);
-        $this->subject->_call('initializeGlobalVariables');
-        $this->assertIsArray($GLOBALS['T3_VAR']);
-    }
-
-    /**
-     * @test
-     */
     public function initializeGlobalVariablesSetsGlobalT3ServicesArray()
     {
         unset($GLOBALS['T3_SERVICES']);
index 2b87b13..097ae77 100644 (file)
@@ -954,7 +954,6 @@ class Indexer
     {
         $localPath = '';
         $pathFunctions = [
-            'createLocalPathFromT3vars',
             'createLocalPathUsingAbsRefPrefix',
             'createLocalPathUsingDomainURL',
             'createLocalPathFromAbsoluteURL',
@@ -970,30 +969,6 @@ class Indexer
     }
 
     /**
-     * Attempts to create a local file path from T3VARs. This is useful for
-     * various download extensions that hide actual file name but still want the
-     * file to be indexed.
-     *
-     * @param string $sourcePath
-     * @return string
-     */
-    protected function createLocalPathFromT3vars($sourcePath)
-    {
-        $localPath = '';
-        $indexLocalFiles = $GLOBALS['T3_VAR']['ext']['indexed_search']['indexLocalFiles'] ?? null;
-        if (is_array($indexLocalFiles)) {
-            $md5 = GeneralUtility::shortMD5($sourcePath);
-            // Note: not using self::isAllowedLocalFile here because this method
-            // is allowed to index files outside of the web site (for example,
-            // protected downloads)
-            if (isset($indexLocalFiles[$md5]) && is_file($indexLocalFiles[$md5])) {
-                $localPath = $indexLocalFiles[$md5];
-            }
-        }
-        return $localPath;
-    }
-
-    /**
      * Attempts to create a local file path by matching a current request URL.
      *
      * @param string $sourcePath
index ecf2bf8..0e25159 100644 (file)
@@ -45,23 +45,6 @@ class IndexerTest extends UnitTestCase
     /**
      * @test
      */
-    public function extractHyperLinksReturnsCorrectFileUsingT3Vars()
-    {
-        $temporaryFileName = tempnam(Environment::getVarPath() . '/tests/', 't3unit-');
-        $this->testFilesToDelete[] = $temporaryFileName;
-        $html = 'test <a href="testfile">test</a> test';
-        $GLOBALS['T3_VAR']['ext']['indexed_search']['indexLocalFiles'] = [
-            \TYPO3\CMS\Core\Utility\GeneralUtility::shortMD5('testfile') => $temporaryFileName,
-        ];
-        $subject = new Indexer();
-        $result = $subject->extractHyperLinks($html);
-        $this->assertEquals(1, count($result));
-        $this->assertEquals($temporaryFileName, $result[0]['localPath']);
-    }
-
-    /**
-     * @test
-     */
     public function extractHyperLinksReturnsCorrectPathWithBaseUrl()
     {
         $baseURL = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL');
index 155cc77..5c6216f 100644 (file)
@@ -316,4 +316,9 @@ return [
             'Breaking-88638-StreamlinedSoftRefParserReferenceLookup.rst',
         ],
     ],
+    '$GLOBALS[\'T3_VAR\'][\'ext\'][\'indexed_search\'][\'indexLocalFiles\']' => [
+        'restFiles' => [
+            'Breaking-88660-GLOBALST3_VARRemoved.rst',
+        ],
+    ],
 ];
index 6f15911..187ae44 100644 (file)
@@ -41,4 +41,9 @@ return [
             'Deprecation-88567-GLOBALS_LOCAL_LANG.rst',
         ],
     ],
+    '$GLOBALS[\'T3_VAR\']' => [
+        'restFiles' => [
+            'Breaking-88660-GLOBALST3_VARRemoved.rst',
+        ],
+    ],
 ];