[TASK] Move TYPO3_version constant to a dedicated class 40/62740/8
authorBenni Mack <benni@typo3.org>
Wed, 18 Dec 2019 12:48:50 +0000 (13:48 +0100)
committerOliver Hader <oliver.hader@typo3.org>
Thu, 9 Jan 2020 09:45:49 +0000 (10:45 +0100)
To optimize TYPO3 for Opcaching and speeding up performance,
as well as simplyfing the bootstrap (also for the testing framework)
the constants
* TYPO3_version
* TYPO3_branch
are moved to a new PHP class "Typo3Version".

This reduces the necessity to define the constants, and since
TYPO3 Bootstrap continues to use the class, the constants
are defined in the constructor for TYPO3 v10, and will be removed
in TYPO3 v11.

Resolves: #90007
Releases: master
Change-Id: I18942023c0e234a328d45f724a6b3092c801982c
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62740
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Oliver Hader <oliver.hader@typo3.org>
Reviewed-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Oliver Hader <oliver.hader@typo3.org>
32 files changed:
typo3/sysext/about/Classes/Controller/AboutController.php
typo3/sysext/backend/Classes/Backend/ToolbarItems/SystemInformationToolbarItem.php
typo3/sysext/backend/Classes/Controller/BackendController.php
typo3/sysext/core/Classes/Console/CommandApplication.php
typo3/sysext/core/Classes/Console/CommandRequestHandler.php
typo3/sysext/core/Classes/Core/Bootstrap.php
typo3/sysext/core/Classes/Core/SystemEnvironmentBuilder.php
typo3/sysext/core/Classes/DependencyInjection/ContainerBuilder.php
typo3/sysext/core/Classes/ExpressionLanguage/SiteConditionProvider.php
typo3/sysext/core/Classes/ExpressionLanguage/TypoScriptConditionProvider.php
typo3/sysext/core/Classes/Http/MiddlewareStackResolver.php
typo3/sysext/core/Classes/Imaging/IconRegistry.php
typo3/sysext/core/Classes/Information/Typo3Version.php [new file with mode: 0644]
typo3/sysext/core/Classes/Package/PackageManager.php
typo3/sysext/core/Classes/Utility/ExtensionManagementUtility.php
typo3/sysext/core/Classes/Utility/VersionNumberUtility.php
typo3/sysext/core/Documentation/Changelog/master/Deprecation-90007-GlobalConstantsTYPO3_versionAndTYPO3_branch.rst [new file with mode: 0644]
typo3/sysext/extbase/Classes/Configuration/RequestHandlersConfigurationFactory.php
typo3/sysext/extbase/Classes/Persistence/ClassesConfigurationFactory.php
typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapFactory.php
typo3/sysext/extbase/Classes/Reflection/ReflectionService.php
typo3/sysext/impexp/Classes/Export.php
typo3/sysext/install/Classes/Controller/AbstractController.php
typo3/sysext/install/Classes/Controller/InstallerController.php
typo3/sysext/install/Classes/Controller/LayoutController.php
typo3/sysext/install/Classes/Report/InstallStatusReport.php
typo3/sysext/install/Classes/Service/CoreVersionService.php
typo3/sysext/install/Classes/ViewHelpers/ConstantViewHelper.php [deleted file]
typo3/sysext/install/Configuration/ExtensionScanner/Php/ConstantMatcher.php
typo3/sysext/install/Resources/Private/Templates/Layout/MainLayout.html
typo3/sysext/install/Tests/Unit/Service/CoreVersionServiceTest.php
typo3/sysext/t3editor/Classes/T3editor.php

index 62aa492..d074e19 100644 (file)
@@ -19,6 +19,7 @@ use TYPO3\CMS\Backend\Module\ModuleLoader;
 use TYPO3\CMS\Backend\Template\ModuleTemplate;
 use TYPO3\CMS\Core\Http\HtmlResponse;
 use TYPO3\CMS\Core\Information\Typo3Copyright;
+use TYPO3\CMS\Core\Information\Typo3Version;
 use TYPO3\CMS\Core\Package\PackageManager;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Fluid\View\StandaloneView;
@@ -43,13 +44,19 @@ class AboutController
      * @var ViewInterface
      */
     protected $view;
+
+    /**
+     * @var Typo3Version
+     */
+    protected $version;
     /**
      * @var \TYPO3\CMS\Core\Information\Typo3Copyright
      */
     private $copyright;
 
-    public function __construct(Typo3Copyright $copyright)
+    public function __construct(Typo3Version $version, Typo3Copyright $copyright)
     {
+        $this->version = $version;
         $this->copyright = $copyright;
     }
 
@@ -74,7 +81,7 @@ class AboutController
         $this->view->assignMultiple([
             'copyrightYear' => $this->copyright->getCopyrightYear(),
             'donationUrl' => TYPO3_URL_DONATE,
-            'currentVersion' => TYPO3_version,
+            'currentVersion' => $this->version->getVersion(),
             'loadedExtensions' => $this->getLoadedExtensions(),
             'copyRightNotice' => $this->copyright->getCopyrightNotice(),
             'warnings' => $warnings,
index 01a8a56..b0340c7 100644 (file)
@@ -21,13 +21,13 @@ use TYPO3\CMS\Backend\Toolbar\Enumeration\InformationStatus;
 use TYPO3\CMS\Backend\Toolbar\ToolbarItemInterface;
 use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Database\ConnectionPool;
+use TYPO3\CMS\Core\Information\Typo3Version;
 use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Page\PageRenderer;
 use TYPO3\CMS\Core\Routing\RouteNotFoundException;
 use TYPO3\CMS\Core\Utility\CommandUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\StringUtility;
-use TYPO3\CMS\Core\Utility\VersionNumberUtility;
 use TYPO3\CMS\Fluid\View\StandaloneView;
 
 /**
@@ -76,9 +76,15 @@ class SystemInformationToolbarItem implements ToolbarItemInterface
      */
     protected $maximumCountInBadge = 99;
 
+    /**
+     * @var Typo3Version
+     */
+    protected $typo3Version;
+
     public function __construct(EventDispatcherInterface $eventDispatcher = null)
     {
         $this->eventDispatcher = $eventDispatcher ?? GeneralUtility::getContainer()->get(EventDispatcherInterface::class);
+        $this->typo3Version = GeneralUtility::makeInstance(Typo3Version::class);
         $this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/Toolbar/SystemInformationMenu');
         $this->highestSeverity = InformationStatus::cast(InformationStatus::STATUS_INFO);
     }
@@ -240,7 +246,7 @@ class SystemInformationToolbarItem implements ToolbarItemInterface
     {
         $this->systemInformation[] = [
             'title' => 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:toolbarItems.sysinfo.typo3-version',
-            'value' => VersionNumberUtility::getCurrentTypo3Version(),
+            'value' => $this->typo3Version->getVersion(),
             'iconIdentifier' => 'information-typo3-version'
         ];
     }
@@ -321,7 +327,7 @@ class SystemInformationToolbarItem implements ToolbarItemInterface
      */
     protected function getGitRevision()
     {
-        if (!StringUtility::endsWith(TYPO3_version, '-dev') || $this->isFunctionDisabled('exec')) {
+        if (!StringUtility::endsWith($this->typo3Version->getVersion(), '-dev') || $this->isFunctionDisabled('exec')) {
             return;
         }
         // check if git exists
index c08b5f2..38a899b 100644 (file)
@@ -25,6 +25,7 @@ use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
 use TYPO3\CMS\Core\Http\HtmlResponse;
 use TYPO3\CMS\Core\Http\JsonResponse;
 use TYPO3\CMS\Core\Imaging\IconFactory;
+use TYPO3\CMS\Core\Information\Typo3Version;
 use TYPO3\CMS\Core\Page\PageRenderer;
 use TYPO3\CMS\Core\Type\Bitmask\Permission;
 use TYPO3\CMS\Core\Type\File\ImageInfo;
@@ -89,6 +90,11 @@ class BackendController
     protected $iconFactory;
 
     /**
+     * @var Typo3Version
+     */
+    protected $typo3Version;
+
+    /**
      * Constructor
      */
     public function __construct()
@@ -98,6 +104,7 @@ class BackendController
         $this->backendModuleRepository = GeneralUtility::makeInstance(BackendModuleRepository::class);
         $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
         $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
+        $this->typo3Version = GeneralUtility::makeInstance(Typo3Version::class);
         // Set debug flag for BE development only
         $this->debug = (int)$GLOBALS['TYPO3_CONF_VARS']['BE']['debug'] === 1;
         // Initializes the backend modules structure for use later.
@@ -219,7 +226,8 @@ class BackendController
         $this->generateJavascript();
 
         // Set document title:
-        $title = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] ? $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] . ' [TYPO3 CMS ' . TYPO3_version . ']' : 'TYPO3 CMS ' . TYPO3_version;
+        $typo3Version = 'TYPO3 CMS ' . $this->typo3Version->getVersion();
+        $title = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] ? $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] . ' [' . $typo3Version . ']' : $typo3Version;
         // Renders the module page
         $this->content = GeneralUtility::makeInstance(DocumentTemplate::class)->render($title, $view->render());
         $hookConfiguration = ['content' => &$this->content];
@@ -266,7 +274,7 @@ class BackendController
         $view->assign('logoUrl', PathUtility::getAbsoluteWebPath($logoPath));
         $view->assign('logoWidth', $logoWidth);
         $view->assign('logoHeight', $logoHeight);
-        $view->assign('applicationVersion', TYPO3_version);
+        $view->assign('applicationVersion', $this->typo3Version->getVersion());
         $view->assign('siteName', $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']);
         $view->assign('toolbar', $this->renderToolbar());
 
@@ -379,7 +387,7 @@ class BackendController
             navFrameHighlightedID: [],         // used by navigation frames to track which row id was highlighted last time
             currentBank: "0"
         };
-    
+
         top.goToModule = function(modName, cMR_flag, addGetVars) {
             TYPO3.ModuleMenu.App.showModule(modName, addGetVars);
         }
index 5032962..4610d88 100644 (file)
@@ -27,6 +27,7 @@ use TYPO3\CMS\Core\Context\WorkspaceAspect;
 use TYPO3\CMS\Core\Core\ApplicationInterface;
 use TYPO3\CMS\Core\Core\Bootstrap;
 use TYPO3\CMS\Core\Core\Environment;
+use TYPO3\CMS\Core\Information\Typo3Version;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
@@ -52,7 +53,7 @@ class CommandApplication implements ApplicationInterface
         $this->checkEnvironmentOrDie();
         $this->application = new Application('TYPO3 CMS', sprintf(
             '%s (Application Context: <comment>%s</comment>)',
-            TYPO3_version,
+            (new Typo3Version())->getVersion(),
             Environment::getContext()
         ));
         $this->application->setAutoExit(false);
index c68a4cb..980151b 100644 (file)
@@ -23,6 +23,7 @@ use Symfony\Component\Console\Output\ConsoleOutput;
 use TYPO3\CMS\Core\Authentication\CommandLineUserAuthentication;
 use TYPO3\CMS\Core\Core\Bootstrap;
 use TYPO3\CMS\Core\Core\Environment;
+use TYPO3\CMS\Core\Information\Typo3Version;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
@@ -46,7 +47,7 @@ class CommandRequestHandler implements RequestHandlerInterface
         trigger_error('CommandRequestHandler will be removed in TYPO3 v11.0, as CLI is executed inside the CommandApplication directly.', E_USER_DEPRECATED);
         $this->application = new Application('TYPO3 CMS', sprintf(
             '%s (Application Context: <comment>%s</comment>)',
-            TYPO3_version,
+            (new Typo3Version())->getVersion(),
             Environment::getContext()
         ));
     }
index 9fcd93e..efb6815 100644 (file)
@@ -30,6 +30,7 @@ use TYPO3\CMS\Core\Cache\Frontend\VariableFrontend;
 use TYPO3\CMS\Core\Configuration\ConfigurationManager;
 use TYPO3\CMS\Core\DependencyInjection\ContainerBuilder;
 use TYPO3\CMS\Core\Imaging\IconRegistry;
+use TYPO3\CMS\Core\Information\Typo3Version;
 use TYPO3\CMS\Core\IO\PharStreamWrapperInterceptor;
 use TYPO3\CMS\Core\Log\LogManager;
 use TYPO3\CMS\Core\Package\FailsafePackageManager;
@@ -535,7 +536,7 @@ class Bootstrap
     public static function initializeBackendRouter()
     {
         // See if the Routes.php from all active packages have been built together already
-        $cacheIdentifier = 'BackendRoutesFromPackages_' . sha1(TYPO3_version . Environment::getProjectPath() . 'BackendRoutesFromPackages');
+        $cacheIdentifier = 'BackendRoutesFromPackages_' . sha1((string)(new Typo3Version()) . Environment::getProjectPath() . 'BackendRoutesFromPackages');
 
         /** @var \TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $codeCache */
         $codeCache = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Cache\CacheManager::class)->getCache('core');
index 0c8f066..ba65404 100644 (file)
@@ -100,13 +100,10 @@ class SystemEnvironmentBuilder
     {
         // Check one of the constants and return early if already defined,
         // needed if multiple requests are handled in one process, for instance in functional testing.
-        if (defined('TYPO3_version')) {
+        if (defined('TYPO3_copyright_year')) {
             return;
         }
 
-        // This version, branch and copyright
-        define('TYPO3_version', '10.3.0-dev');
-        define('TYPO3_branch', '10.3');
         define('TYPO3_copyright_year', '1998-' . date('Y'));
 
         // TYPO3 external links
index d9414c0..66a23bb 100644 (file)
@@ -23,6 +23,7 @@ use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
 use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
 use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
 use TYPO3\CMS\Core\Core\Environment;
+use TYPO3\CMS\Core\Information\Typo3Version;
 use TYPO3\CMS\Core\Package\PackageManager;
 
 /**
@@ -178,6 +179,6 @@ class ContainerBuilder
      */
     protected function createCacheIdentifier(): string
     {
-        return $this->cacheIdentifier = 'DependencyInjectionContainer_' . sha1(TYPO3_version . Environment::getProjectPath() . 'DependencyInjectionContainer');
+        return $this->cacheIdentifier = 'DependencyInjectionContainer_' . sha1((string)(new Typo3Version()) . Environment::getProjectPath() . 'DependencyInjectionContainer');
     }
 }
index 937c937..eae6881 100644 (file)
@@ -17,14 +17,17 @@ namespace TYPO3\CMS\Core\ExpressionLanguage;
  */
 
 use TYPO3\CMS\Core\Core\Environment;
+use TYPO3\CMS\Core\Information\Typo3Version;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 class SiteConditionProvider extends AbstractProvider
 {
     public function __construct()
     {
         $typo3 = new \stdClass();
-        $typo3->version = TYPO3_version;
-        $typo3->branch = TYPO3_branch;
+        $typo3Version = GeneralUtility::makeInstance(Typo3Version::class);
+        $typo3->version = $typo3Version->getVersion();
+        $typo3->branch = $typo3Version->getBranch();
         $typo3->devIpMask = trim($GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask']);
         $this->expressionLanguageVariables = [
             'applicationContext' => (string)Environment::getContext(),
index 56211f1..9df771e 100644 (file)
@@ -18,6 +18,7 @@ namespace TYPO3\CMS\Core\ExpressionLanguage;
 
 use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\ExpressionLanguage\FunctionsProvider\Typo3ConditionFunctionsProvider;
+use TYPO3\CMS\Core\Information\Typo3Version;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
@@ -30,8 +31,9 @@ class TypoScriptConditionProvider extends AbstractProvider
     public function __construct()
     {
         $typo3 = new \stdClass();
-        $typo3->version = TYPO3_version;
-        $typo3->branch = TYPO3_branch;
+        $typo3Version = GeneralUtility::makeInstance(Typo3Version::class);
+        $typo3->version = $typo3Version->getVersion();
+        $typo3->branch = $typo3Version->getBranch();
         $typo3->devIpMask = trim($GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask']);
         $this->expressionLanguageVariables = [
             'request' => GeneralUtility::makeInstance(RequestWrapper::class, $GLOBALS['TYPO3_REQUEST'] ?? null),
index e290990..ba30140 100644 (file)
@@ -19,6 +19,7 @@ use ArrayObject;
 use Psr\Container\ContainerInterface;
 use TYPO3\CMS\Core\Cache\Frontend\PhpFrontend as PhpFrontendCache;
 use TYPO3\CMS\Core\Core\Environment;
+use TYPO3\CMS\Core\Information\Typo3Version;
 use TYPO3\CMS\Core\Service\DependencyOrderingService;
 
 /**
@@ -130,6 +131,6 @@ class MiddlewareStackResolver
      */
     protected function getCacheIdentifier(string $stackName): string
     {
-        return 'middlewares_' . $stackName . '_' . sha1(TYPO3_version . Environment::getProjectPath());
+        return 'middlewares_' . $stackName . '_' . sha1((string)(new Typo3Version()) . Environment::getProjectPath());
     }
 }
index e08a8e3..4ee04ca 100644 (file)
@@ -22,6 +22,7 @@ use TYPO3\CMS\Core\Exception;
 use TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider;
 use TYPO3\CMS\Core\Imaging\IconProvider\FontawesomeIconProvider;
 use TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider;
+use TYPO3\CMS\Core\Information\Typo3Version;
 use TYPO3\CMS\Core\SingletonInterface;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\StringUtility;
@@ -503,7 +504,7 @@ class IconRegistry implements SingletonInterface
      */
     protected function getCachedBackendIcons()
     {
-        $cacheIdentifier = 'BackendIcons_' . sha1(TYPO3_version . Environment::getProjectPath() . 'BackendIcons');
+        $cacheIdentifier = 'BackendIcons_' . sha1((string)(new Typo3Version()) . Environment::getProjectPath() . 'BackendIcons');
         /** @var \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend $assetsCache */
         $assetsCache = static::$cache ?? GeneralUtility::makeInstance(CacheManager::class)->getCache('assets');
         $cacheEntry = $assetsCache->get($cacheIdentifier);
diff --git a/typo3/sysext/core/Classes/Information/Typo3Version.php b/typo3/sysext/core/Classes/Information/Typo3Version.php
new file mode 100644 (file)
index 0000000..b8242ee
--- /dev/null
@@ -0,0 +1,61 @@
+<?php
+declare(strict_types = 1);
+namespace TYPO3\CMS\Core\Information;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+class Typo3Version
+{
+    protected const VERSION = '10.3.0-dev';
+    protected const BRANCH = '10.3';
+
+    /**
+     * Define constants used up until TYPO3 v10, this constructor can be removed in TYPO3 v11.
+     */
+    public function __construct()
+    {
+        if (!defined('TYPO3_version')) {
+            define('TYPO3_version', $this->getVersion());
+        }
+        if (!defined('TYPO3_branch')) {
+            define('TYPO3_branch', $this->getBranch());
+        }
+    }
+
+    public function getVersion(): string
+    {
+        return static::VERSION;
+    }
+
+    public function getBranch(): string
+    {
+        return static::BRANCH;
+    }
+
+    /**
+     * Get 'major version' of version, e.g., '7' from '7.3.0'
+     *
+     * @return int Major version, e.g., '7'
+     */
+    public function getMajorVersion(): int
+    {
+        [$explodedVersion] = explode('.', static::VERSION);
+        return (int)$explodedVersion;
+    }
+
+    public function __toString(): string
+    {
+        return $this->getVersion();
+    }
+}
index 89137d6..3c135d6 100644 (file)
@@ -19,6 +19,7 @@ use Symfony\Component\Finder\SplFileInfo;
 use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
 use TYPO3\CMS\Core\Core\ClassLoadingInformation;
 use TYPO3\CMS\Core\Core\Environment;
+use TYPO3\CMS\Core\Information\Typo3Version;
 use TYPO3\CMS\Core\Service\DependencyOrderingService;
 use TYPO3\CMS\Core\Service\OpcodeCacheService;
 use TYPO3\CMS\Core\SingletonInterface;
@@ -143,7 +144,7 @@ class PackageManager implements SingletonInterface
         if ($this->cacheIdentifier === null) {
             $mTime = @filemtime($this->packageStatesPathAndFilename);
             if ($mTime !== false) {
-                $this->cacheIdentifier = md5(TYPO3_version . $this->packageStatesPathAndFilename . $mTime);
+                $this->cacheIdentifier = md5((string)(new Typo3Version()) . $this->packageStatesPathAndFilename . $mTime);
             } else {
                 $this->cacheIdentifier = null;
             }
index 70057e6..37a6828 100644 (file)
@@ -24,6 +24,7 @@ use TYPO3\CMS\Core\Category\CategoryRegistry;
 use TYPO3\CMS\Core\Configuration\Event\AfterTcaCompilationEvent;
 use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Imaging\IconRegistry;
+use TYPO3\CMS\Core\Information\Typo3Version;
 use TYPO3\CMS\Core\Log\LogManager;
 use TYPO3\CMS\Core\Migrations\TcaMigration;
 use TYPO3\CMS\Core\Package\PackageManager;
@@ -1505,7 +1506,7 @@ tt_content.' . $key . $suffix . ' {
      */
     protected static function getExtLocalconfCacheIdentifier()
     {
-        return 'ext_localconf_' . sha1(TYPO3_version . Environment::getProjectPath() . 'extLocalconf' . serialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['runtimeActivatedPackages']));
+        return 'ext_localconf_' . sha1((string)(new Typo3Version()) . Environment::getProjectPath() . 'extLocalconf' . serialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['runtimeActivatedPackages']));
     }
 
     /**
@@ -1643,7 +1644,7 @@ tt_content.' . $key . $suffix . ' {
      */
     protected static function getBaseTcaCacheIdentifier()
     {
-        return 'tca_base_' . sha1(TYPO3_version . Environment::getProjectPath() . 'tca_code' . serialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['runtimeActivatedPackages']));
+        return 'tca_base_' . sha1((string)(new Typo3Version()) . Environment::getProjectPath() . 'tca_code' . serialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['runtimeActivatedPackages']));
     }
 
     /**
@@ -1729,7 +1730,7 @@ tt_content.' . $key . $suffix . ' {
      */
     protected static function getExtTablesCacheIdentifier()
     {
-        return 'ext_tables_' . sha1(TYPO3_version . Environment::getProjectPath() . 'extTables' . serialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['runtimeActivatedPackages']));
+        return 'ext_tables_' . sha1((string)(new Typo3Version()) . Environment::getProjectPath() . 'extTables' . serialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['runtimeActivatedPackages']));
     }
 
     /**
index c631fc7..27de1bf 100644 (file)
@@ -14,6 +14,8 @@ namespace TYPO3\CMS\Core\Utility;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Information\Typo3Version;
+
 /**
  * Class with helper functions for version number handling
  */
@@ -119,7 +121,7 @@ class VersionNumberUtility
      */
     public static function getCurrentTypo3Version()
     {
-        return TYPO3_version;
+        return (string)GeneralUtility::makeInstance(Typo3Version::class);
     }
 
     /**
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-90007-GlobalConstantsTYPO3_versionAndTYPO3_branch.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-90007-GlobalConstantsTYPO3_versionAndTYPO3_branch.rst
new file mode 100644 (file)
index 0000000..1a609be
--- /dev/null
@@ -0,0 +1,43 @@
+.. include:: ../../Includes.txt
+
+=====================================================================
+Deprecation: #90007 - Global constants TYPO3_version and TYPO3_branch
+=====================================================================
+
+See :issue:`90007`
+
+Description
+===========
+
+Two of the most "stable" global constants in the TYPO3 Core - `TYPO3_version` and `TYPO3_branch` have been marked as deprecated.
+
+The change was mainly driven by the necessity to minimize runtime-generated constants in order to optimize performance, also for op-caching.
+
+The same information is available in a new PHP class :php:`TYPO3\CMS\Core\Information\Typo3Version`, which also defines
+the constants for backwards-compatibility reasons.
+
+
+Impact
+======
+
+No :php:`E_USER_DEPRECATED` error is triggered, however the constants will work during
+TYPO3 v10, and be removed with TYPO3 v11.
+
+
+Affected Installations
+======================
+
+TYPO3 installations with custom extensions accessing the constants,
+which is common for having extension support for multiple TYPO3 versions.
+
+
+Migration
+=========
+
+It is highly recommended to use the :php:`Typo3Version` class instead of
+the constants, as they will removed.
+
+Check the Extension Scanner in the Upgrade section of TYPO3 to see
+if any extensions you use might be affected.
+
+.. index:: PHP-API, FullyScanned, ext:core
\ No newline at end of file
index a4f8156..6da51c0 100644 (file)
@@ -20,6 +20,7 @@ use TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException;
 use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
 use TYPO3\CMS\Core\Cache\Frontend\NullFrontend;
 use TYPO3\CMS\Core\Core\Environment;
+use TYPO3\CMS\Core\Information\Typo3Version;
 use TYPO3\CMS\Core\Package\PackageManager;
 use TYPO3\CMS\Core\SingletonInterface;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -61,7 +62,7 @@ final class RequestHandlersConfigurationFactory implements SingletonInterface
      */
     public function createRequestHandlersConfiguration(): RequestHandlersConfiguration
     {
-        $cacheEntryIdentifier = 'RequestHandlers_' . sha1(TYPO3_version . Environment::getProjectPath());
+        $cacheEntryIdentifier = 'RequestHandlers_' . sha1((string)(new Typo3Version()) . Environment::getProjectPath());
 
         if ($this->cacheFrontend->has($cacheEntryIdentifier)) {
             return new RequestHandlersConfiguration($this->cacheFrontend->get($cacheEntryIdentifier));
index baf346f..c9e2a98 100644 (file)
@@ -19,6 +19,7 @@ use TYPO3\CMS\Core\Cache\CacheManager;
 use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
 use TYPO3\CMS\Core\Cache\Frontend\NullFrontend;
 use TYPO3\CMS\Core\Core\Environment;
+use TYPO3\CMS\Core\Information\Typo3Version;
 use TYPO3\CMS\Core\Package\PackageManager;
 use TYPO3\CMS\Core\SingletonInterface;
 use TYPO3\CMS\Core\Utility\ArrayUtility;
@@ -61,7 +62,7 @@ final class ClassesConfigurationFactory implements SingletonInterface
      */
     public function createClassesConfiguration(): ClassesConfiguration
     {
-        $cacheEntryIdentifier = 'PersistenceClasses_' . sha1(TYPO3_version . Environment::getProjectPath());
+        $cacheEntryIdentifier = 'PersistenceClasses_' . sha1((new Typo3Version())->getVersion() . Environment::getProjectPath());
 
         if ($this->cacheFrontend->has($cacheEntryIdentifier)) {
             return new ClassesConfiguration($this->cacheFrontend->get($cacheEntryIdentifier));
index dde3f4c..dc17ebb 100644 (file)
@@ -18,6 +18,7 @@ namespace TYPO3\CMS\Extbase\Persistence\Generic\Mapper;
 
 use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Database\Query\QueryHelper;
+use TYPO3\CMS\Core\Information\Typo3Version;
 use TYPO3\CMS\Extbase\Persistence\ClassesConfiguration;
 use TYPO3\CMS\Extbase\Persistence\ClassesConfigurationFactory;
 use TYPO3\CMS\Extbase\Reflection\ClassSchema\Exception\NoSuchPropertyException;
@@ -102,7 +103,7 @@ class DataMapFactory implements \TYPO3\CMS\Core\SingletonInterface
             return $this->dataMaps[$className];
         }
         $cacheIdentifierClassName = str_replace('\\', '', $className);
-        $cacheIdentifier = 'DataMap_' . $cacheIdentifierClassName . '_' . sha1(TYPO3_version . Environment::getProjectPath());
+        $cacheIdentifier = 'DataMap_' . $cacheIdentifierClassName . '_' . sha1((string)(new Typo3Version()) . Environment::getProjectPath());
         $dataMap = $this->dataMapCache->get($cacheIdentifier);
         if ($dataMap === false) {
             $dataMap = $this->buildDataMapInternal($className);
index 4498489..b062be1 100644 (file)
@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Extbase\Reflection;
 
 use TYPO3\CMS\Core\Cache\CacheManager;
 use TYPO3\CMS\Core\Core\Environment;
+use TYPO3\CMS\Core\Information\Typo3Version;
 use TYPO3\CMS\Core\SingletonInterface;
 
 /**
@@ -68,7 +69,7 @@ class ReflectionService implements SingletonInterface
             $this->cachingEnabled = true;
             $this->dataCache = $cacheManager->getCache('extbase');
 
-            static::$cacheEntryIdentifier = 'ClassSchemata_' . sha1(TYPO3_version . Environment::getProjectPath());
+            static::$cacheEntryIdentifier = 'ClassSchemata_' . sha1((string)(new Typo3Version()) . Environment::getProjectPath());
             if (($classSchemata = $this->dataCache->get(static::$cacheEntryIdentifier)) !== false) {
                 $this->classSchemata = $classSchemata;
             }
index 95fda69..f9d0c84 100644 (file)
@@ -19,6 +19,7 @@ use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Database\ReferenceIndex;
 use TYPO3\CMS\Core\Exception;
 use TYPO3\CMS\Core\Html\HtmlParser;
+use TYPO3\CMS\Core\Information\Typo3Version;
 use TYPO3\CMS\Core\Resource\File;
 use TYPO3\CMS\Core\Resource\ResourceFactory;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -184,7 +185,7 @@ class Export extends ImportExport
             'packager_username' => $packager_username,
             'packager_name' => $packager_name,
             'packager_email' => $packager_email,
-            'TYPO3_version' => TYPO3_version,
+            'TYPO3_version' => (string)GeneralUtility::makeInstance(Typo3Version::class),
             'created' => strftime('%A %e. %B %Y', $GLOBALS['EXEC_TIME'])
         ];
     }
index b72a637..4997f7e 100644 (file)
@@ -18,6 +18,7 @@ namespace TYPO3\CMS\Install\Controller;
 use Psr\Container\ContainerInterface;
 use Psr\Http\Message\ServerRequestInterface;
 use TYPO3\CMS\Core\Core\Environment;
+use TYPO3\CMS\Core\Information\Typo3Version;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Fluid\View\StandaloneView;
 use TYPO3\CMS\Install\Service\LateBootService;
@@ -48,6 +49,7 @@ class AbstractController
             'controller' => $request->getQueryParams()['install']['controller'] ?? 'maintenance',
             'context' => $request->getQueryParams()['install']['context'] ?? '',
             'composerMode' => Environment::isComposerMode(),
+            'currentTypo3Version' => (string)(new Typo3Version())
         ]);
         return $view;
     }
index 75474e7..0811480 100644 (file)
@@ -40,6 +40,7 @@ use TYPO3\CMS\Core\FormProtection\InstallToolFormProtection;
 use TYPO3\CMS\Core\Http\HtmlResponse;
 use TYPO3\CMS\Core\Http\JsonResponse;
 use TYPO3\CMS\Core\Http\NormalizedParams;
+use TYPO3\CMS\Core\Information\Typo3Version;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\Messaging\FlashMessageQueue;
 use TYPO3\CMS\Core\Package\PackageInterface;
@@ -71,7 +72,7 @@ class InstallerController
     {
         $bust = $GLOBALS['EXEC_TIME'];
         if (!Environment::getContext()->isDevelopment()) {
-            $bust = GeneralUtility::hmac(TYPO3_version . Environment::getProjectPath());
+            $bust = GeneralUtility::hmac((string)(new Typo3Version()) . Environment::getProjectPath());
         }
         $view = $this->initializeStandaloneView('Installer/Init.html');
         $view->assign('bust', $bust);
index f7a0d9c..e31298f 100644 (file)
@@ -21,6 +21,7 @@ use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
 use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Http\HtmlResponse;
 use TYPO3\CMS\Core\Http\JsonResponse;
+use TYPO3\CMS\Core\Information\Typo3Version;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Install\Service\Exception\ConfigurationChangedException;
 use TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService;
@@ -45,7 +46,7 @@ class LayoutController extends AbstractController
     {
         $bust = $GLOBALS['EXEC_TIME'];
         if (!Environment::getContext()->isDevelopment()) {
-            $bust = GeneralUtility::hmac(TYPO3_version . Environment::getProjectPath());
+            $bust = GeneralUtility::hmac((string)(new Typo3Version()) . Environment::getProjectPath());
         }
         $view = $this->initializeStandaloneView($request, 'Layout/Init.html');
         $view->assignMultiple([
index 2c919e3..cd61d05 100644 (file)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Install\Report;
  */
 
 use TYPO3\CMS\Core\Core\Environment;
+use TYPO3\CMS\Core\Information\Typo3Version;
 use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Install\Service\Exception;
@@ -195,13 +196,14 @@ class InstallStatusReport implements \TYPO3\CMS\Reports\StatusProviderInterface
      */
     protected function getNewVersionStatus()
     {
+        $typoVersion = GeneralUtility::makeInstance(Typo3Version::class);
         $languageService = $this->getLanguageService();
         /** @var \TYPO3\CMS\Install\Service\CoreVersionService $coreVersionService */
         $coreVersionService = GeneralUtility::makeInstance(\TYPO3\CMS\Install\Service\CoreVersionService::class);
 
         // No updates for development versions
         if (!$coreVersionService->isInstalledVersionAReleasedVersion()) {
-            return GeneralUtility::makeInstance(Status::class, 'TYPO3', TYPO3_version, $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_isDevelopmentVersion'), Status::NOTICE);
+            return GeneralUtility::makeInstance(Status::class, 'TYPO3', $typoVersion->getVersion(), $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_isDevelopmentVersion'), Status::NOTICE);
         }
 
         try {
@@ -211,7 +213,7 @@ class InstallStatusReport implements \TYPO3\CMS\Reports\StatusProviderInterface
             return GeneralUtility::makeInstance(
                 Status::class,
                 'TYPO3',
-                TYPO3_version,
+                $typoVersion->getVersion(),
                 $languageService->sL(
                     'LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_remoteFetchException'
                 ),
@@ -239,7 +241,7 @@ class InstallStatusReport implements \TYPO3\CMS\Reports\StatusProviderInterface
             $status = Status::ERROR;
         }
 
-        return GeneralUtility::makeInstance(Status::class, 'TYPO3', TYPO3_version, $message, $status);
+        return GeneralUtility::makeInstance(Status::class, 'TYPO3', $typoVersion->getVersion(), $message, $status);
     }
 
     /**
index c8d61b9..3eb33d0 100644 (file)
@@ -16,9 +16,9 @@ namespace TYPO3\CMS\Install\Service;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Information\Typo3Version;
 use TYPO3\CMS\Core\Registry;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Core\Utility\VersionNumberUtility;
 
 /**
  * Core version service
@@ -80,7 +80,7 @@ class CoreVersionService
      */
     public function getInstalledVersion(): string
     {
-        return VersionNumberUtility::getCurrentTypo3Version();
+        return (string)GeneralUtility::makeInstance(Typo3Version::class);
     }
 
     /**
@@ -165,19 +165,7 @@ class CoreVersionService
      */
     protected function getInstalledMajorVersion(): string
     {
-        return $this->getMajorVersion($this->getInstalledVersion());
-    }
-
-    /**
-     * Get 'major version' of version, e.g., '7' from '7.3.0'
-     *
-     * @param string $version to check
-     * @return string Major version, e.g., '7'
-     */
-    protected function getMajorVersion(string $version): string
-    {
-        $explodedVersion = explode('.', $version);
-        return $explodedVersion[0];
+        return (string)GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion();
     }
 
     /**
diff --git a/typo3/sysext/install/Classes/ViewHelpers/ConstantViewHelper.php b/typo3/sysext/install/Classes/ViewHelpers/ConstantViewHelper.php
deleted file mode 100644 (file)
index 8e185f3..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-<?php
-namespace TYPO3\CMS\Install\ViewHelpers;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
-use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
-use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
-
-/**
- * Render value of a constant
- *
- * @internal
- */
-class ConstantViewHelper extends AbstractViewHelper
-{
-    use CompileWithRenderStatic;
-
-    /**
-     * Initialize arguments
-     */
-    public function initializeArguments()
-    {
-        $this->registerArgument('name', 'string', 'Name of the constant', true);
-    }
-
-    /**
-     * Render a constant
-     *
-     * @param array $arguments
-     * @param \Closure $renderChildrenClosure
-     * @param RenderingContextInterface $renderingContext
-     *
-     * @return string Value of constant
-     */
-    public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
-    {
-        return constant($arguments['name']);
-    }
-}
index ee8ce48..b61d9e1 100644 (file)
@@ -179,5 +179,15 @@ return [
             'Deprecation-85285-DeprecatedSystemConstants.rst',
             'Breaking-87193-DeprecatedFunctionalityRemoved.rst',
         ]
-    ]
+    ],
+    'TYPO3_version' => [
+        'restFiles' => [
+            'Deprecation-90007-GlobalConstantsTYPO3_versionAndTYPO3_branch.rst'
+        ]
+    ],
+    'TYPO3_branch' => [
+        'restFiles' => [
+            'Deprecation-90007-GlobalConstantsTYPO3_versionAndTYPO3_branch.rst'
+        ]
+    ],
 ];
index fcae3d9..9773ba9 100644 (file)
@@ -38,7 +38,7 @@
                                     </span>
                                     <span class="topbar-header-site-title">
                                         <span class="topbar-header-site-name">Admin tool on site: {siteName}</span>
-                                        <span class="topbar-header-site-version">TYPO3 CMS <i:constant name="TYPO3_version" /></span>
+                                        <span class="topbar-header-site-version">TYPO3 CMS {currentTypo3Version}</span>
                                     </span>
                                 </a>
                                 <button type="button" class="btn btn-default btn-danger pull-right t3js-login-lockInstallTool" style="margin-top: 7px; margin-right: 15px;">
index 7485fde..b3145fe 100644 (file)
@@ -105,8 +105,8 @@ class CoreVersionServiceTest extends UnitTestCase
             ]
         );
 
-        $instance = $this->getAccessibleMock(CoreVersionService::class, ['getInstalledVersion']);
-        $instance->expects(self::once())->method('getInstalledVersion')->willReturn('9.1.0');
+        $instance = $this->getAccessibleMock(CoreVersionService::class, ['getInstalledMajorVersion']);
+        $instance->expects(self::once())->method('getInstalledMajorVersion')->willReturn('9');
 
         $result = $instance->isVersionActivelyMaintained();
 
@@ -128,8 +128,8 @@ class CoreVersionServiceTest extends UnitTestCase
             ]
         );
 
-        $instance = $this->getAccessibleMock(CoreVersionService::class, ['getInstalledVersion']);
-        $instance->expects(self::once())->method('getInstalledVersion')->willReturn('9.1.0');
+        $instance = $this->getAccessibleMock(CoreVersionService::class, ['getInstalledMajorVersion']);
+        $instance->expects(self::once())->method('getInstalledMajorVersion')->willReturn('9');
 
         $result = $instance->isVersionActivelyMaintained();
 
@@ -151,8 +151,8 @@ class CoreVersionServiceTest extends UnitTestCase
             ]
         );
 
-        $instance = $this->getAccessibleMock(CoreVersionService::class, ['getInstalledVersion']);
-        $instance->expects(self::once())->method('getInstalledVersion')->willReturn('7.6.25');
+        $instance = $this->getAccessibleMock(CoreVersionService::class, ['getInstalledMajorVersion']);
+        $instance->expects(self::once())->method('getInstalledMajorVersion')->willReturn('7');
 
         $result = $instance->isVersionActivelyMaintained();
 
@@ -173,7 +173,8 @@ class CoreVersionServiceTest extends UnitTestCase
             ]
         );
 
-        $instance = $this->getAccessibleMock(CoreVersionService::class, ['getInstalledVersion']);
+        $instance = $this->getAccessibleMock(CoreVersionService::class, ['getInstalledVersion', 'getInstalledMajorVersion']);
+        $instance->expects(self::atLeastOnce())->method('getInstalledMajorVersion')->willReturn('9');
         $instance->expects(self::atLeastOnce())->method('getInstalledVersion')->willReturn('9.0.0');
 
         $result = $instance->isYoungerPatchReleaseAvailable();
@@ -195,7 +196,8 @@ class CoreVersionServiceTest extends UnitTestCase
             ]
         );
 
-        $instance = $this->getAccessibleMock(CoreVersionService::class, ['getInstalledVersion']);
+        $instance = $this->getAccessibleMock(CoreVersionService::class, ['getInstalledVersion', 'getInstalledMajorVersion']);
+        $instance->expects(self::atLeastOnce())->method('getInstalledMajorVersion')->willReturn('9');
         $instance->expects(self::atLeastOnce())->method('getInstalledVersion')->willReturn('9.1.0');
 
         $result = $instance->isYoungerPatchReleaseAvailable();
@@ -217,7 +219,8 @@ class CoreVersionServiceTest extends UnitTestCase
             ]
         );
 
-        $instance = $this->getAccessibleMock(CoreVersionService::class, ['getInstalledVersion']);
+        $instance = $this->getAccessibleMock(CoreVersionService::class, ['getInstalledVersion', 'getInstalledMajorVersion']);
+        $instance->expects(self::atLeastOnce())->method('getInstalledMajorVersion')->willReturn('8');
         $instance->expects(self::atLeastOnce())->method('getInstalledVersion')->willReturn('8.7.1');
 
         $result = $instance->isUpdateSecurityRelevant();
@@ -239,8 +242,9 @@ class CoreVersionServiceTest extends UnitTestCase
             ]
         );
 
-        $instance = $this->getAccessibleMock(CoreVersionService::class, ['getInstalledVersion']);
+        $instance = $this->getAccessibleMock(CoreVersionService::class, ['getInstalledVersion', 'getInstalledMajorVersion']);
         $instance->expects(self::atLeastOnce())->method('getInstalledVersion')->willReturn('8.7.5');
+        $instance->expects(self::atLeastOnce())->method('getInstalledMajorVersion')->willReturn('8');
 
         $result = $instance->isUpdateSecurityRelevant();
 
@@ -261,8 +265,8 @@ class CoreVersionServiceTest extends UnitTestCase
             ]
         );
 
-        $instance = $this->getAccessibleMock(CoreVersionService::class, ['getInstalledVersion']);
-        $instance->expects(self::atLeastOnce())->method('getInstalledVersion')->willReturn('9.0.0');
+        $instance = $this->getAccessibleMock(CoreVersionService::class, ['getInstalledMajorVersion']);
+        $instance->expects(self::atLeastOnce())->method('getInstalledMajorVersion')->willReturn('9');
 
         $result = $instance->getYoungestPatchRelease();
 
@@ -270,41 +274,6 @@ class CoreVersionServiceTest extends UnitTestCase
     }
 
     /**
-     * Data provider
-     */
-    public function getMajorVersionDataProvider(): array
-    {
-        return [
-            '7.2' => [
-                '7.2.0',
-                '7',
-            ],
-            '7.4-dev' => [
-                '7.4-dev',
-                '7',
-            ],
-            '4.5' => [
-                '4.5.40',
-                '4',
-            ],
-        ];
-    }
-
-    /**
-     * @test
-     * @dataProvider getMajorVersionDataProvider
-     * @param string $version
-     * @param string $expectedMajor
-     * @throws \InvalidArgumentException
-     */
-    public function getMajorVersionReturnsCorrectMajorVersion($version, $expectedMajor): void
-    {
-        /** @var $instance CoreVersionService|\TYPO3\TestingFramework\Core\AccessibleObjectInterface|\PHPUnit\Framework\MockObject\MockObject */
-        $instance = $this->getAccessibleMock(CoreVersionService::class, ['dummy'], [], '', false);
-        self::assertSame($expectedMajor, $instance->_call('getMajorVersion', $version));
-    }
-
-    /**
      * @test
      */
     public function isInstalledVersionAReleasedVersionReturnsTrueForNonDevelopmentVersion(): void
index 327f0d6..3c39750 100644 (file)
@@ -18,6 +18,7 @@ namespace TYPO3\CMS\T3editor;
 use TYPO3\CMS\Core\Cache\CacheManager;
 use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
 use TYPO3\CMS\Core\Core\Environment;
+use TYPO3\CMS\Core\Information\Typo3Version;
 use TYPO3\CMS\Core\Package\PackageManager;
 use TYPO3\CMS\Core\SingletonInterface;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -141,7 +142,7 @@ class T3editor implements SingletonInterface
      */
     protected function generateCacheIdentifier(string $key): string
     {
-        return $key . '_' . sha1(TYPO3_version . Environment::getProjectPath() . $key);
+        return $key . '_' . sha1((string)(new Typo3Version()) . Environment::getProjectPath() . $key);
     }
 
     /**