[TASK] Move constant declaration to class constants 24/62624/9
authorBenni Mack <benni@typo3.org>
Fri, 13 Dec 2019 15:24:57 +0000 (16:24 +0100)
committerGeorg Ringer <georg.ringer@gmail.com>
Fri, 10 Jan 2020 14:07:25 +0000 (15:07 +0100)
Using Class constants instead of constants that are defined during
runtime has the following benefits:

- Naming can be made more consistent (and separated)
- Speeding up requests where the constants are not needed
- Benefit from Opcaching of class loading instead of dynamic runtime definition
- Testing framework has less "bootstrap" to do

This affects the following constants:
- TYPO3_copyright_year
- TYPO3_URL_GENERAL
- TYPO3_URL_LICENSE
- TYPO3_URL_EXCEPTION
- TYPO3_URL_DONATE
- TYPO3_URL_WIKI_OPCODECACHE

The constants are now deprecated.

In addition, the "Typo3Copyright" class is now called "TYPO3Information".

Resolves: #89866
Releases: master
Change-Id: I607c90cb281179bda9875504d258daefd3471868
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62624
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
21 files changed:
typo3/sysext/about/Classes/Controller/AboutController.php
typo3/sysext/backend/Classes/Controller/HelpController.php
typo3/sysext/backend/Classes/Controller/LoginController.php
typo3/sysext/backend/Classes/Template/DocumentTemplate.php
typo3/sysext/backend/Classes/Utility/BackendUtility.php
typo3/sysext/core/Classes/Controller/ErrorPageController.php
typo3/sysext/core/Classes/Core/SystemEnvironmentBuilder.php
typo3/sysext/core/Classes/Error/DebugExceptionHandler.php
typo3/sysext/core/Classes/Information/Typo3Copyright.php [deleted file]
typo3/sysext/core/Classes/Information/Typo3Information.php [new file with mode: 0644]
typo3/sysext/core/Documentation/Changelog/10.2/Deprecation-89756-BackendUtilityTYPO3_copyRightNotice.rst
typo3/sysext/core/Documentation/Changelog/master/Deprecation-89866-Global-TYPO3-information-related-constants.rst [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Error/ProductionExceptionHandlerTest.php
typo3/sysext/frontend/Classes/Http/RequestHandler.php
typo3/sysext/frontend/Tests/Unit/Controller/ErrorControllerTest.php
typo3/sysext/frontend/Tests/Unit/Http/RequestHandlerTest.php
typo3/sysext/frontend/Tests/Unit/Middleware/PageArgumentValidatorTest.php
typo3/sysext/install/Classes/SystemEnvironment/Check.php
typo3/sysext/install/Classes/SystemEnvironment/SetupCheck.php
typo3/sysext/install/Configuration/ExtensionScanner/Php/ConstantMatcher.php
typo3/sysext/workspaces/Classes/Controller/PreviewController.php

index d074e19..22a918f 100644 (file)
@@ -18,7 +18,7 @@ use Psr\Http\Message\ResponseInterface;
 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\Typo3Information;
 use TYPO3\CMS\Core\Information\Typo3Version;
 use TYPO3\CMS\Core\Package\PackageManager;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -49,15 +49,16 @@ class AboutController
      * @var Typo3Version
      */
     protected $version;
+
     /**
-     * @var \TYPO3\CMS\Core\Information\Typo3Copyright
+     * @var Typo3Information
      */
-    private $copyright;
+    protected $typo3Information;
 
-    public function __construct(Typo3Version $version, Typo3Copyright $copyright)
+    public function __construct(Typo3Version $version, Typo3Information $typo3Information)
     {
         $this->version = $version;
-        $this->copyright = $copyright;
+        $this->typo3Information = $typo3Information;
     }
 
     /**
@@ -79,11 +80,11 @@ class AboutController
         }
 
         $this->view->assignMultiple([
-            'copyrightYear' => $this->copyright->getCopyrightYear(),
-            'donationUrl' => TYPO3_URL_DONATE,
+            'copyrightYear' => $this->typo3Information->getCopyrightYear(),
+            'donationUrl' => $this->typo3Information::URL_DONATE,
             'currentVersion' => $this->version->getVersion(),
             'loadedExtensions' => $this->getLoadedExtensions(),
-            'copyRightNotice' => $this->copyright->getCopyrightNotice(),
+            'copyRightNotice' => $this->typo3Information->getCopyrightNotice(),
             'warnings' => $warnings,
             'modules' => $this->getModulesData()
         ]);
index a8c40fb..c044ea2 100644 (file)
@@ -24,7 +24,7 @@ use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\Http\HtmlResponse;
 use TYPO3\CMS\Core\Http\RedirectResponse;
 use TYPO3\CMS\Core\Imaging\Icon;
-use TYPO3\CMS\Core\Information\Typo3Copyright;
+use TYPO3\CMS\Core\Information\Typo3Information;
 use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Fluid\View\StandaloneView;
@@ -56,21 +56,22 @@ class HelpController
 
     /** @var ViewInterface */
     protected $view;
+
     /**
-     * @var Typo3Copyright
+     * @var Typo3Information
      */
-    private $copyright;
+    protected $typo3Information;
 
     /**
      * Instantiate the report controller
      *
-     * @param Typo3Copyright $copyright
+     * @param Typo3Information $typo3Information
      */
-    public function __construct(Typo3Copyright $copyright)
+    public function __construct(Typo3Information $typo3Information)
     {
         $this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
         $this->tableManualRepository = GeneralUtility::makeInstance(TableManualRepository::class);
-        $this->copyright = $copyright;
+        $this->typo3Information = $typo3Information;
     }
 
     /**
@@ -117,7 +118,7 @@ class HelpController
         $this->view->setPartialRootPaths(['EXT:backend/Resources/Private/Partials']);
         $this->view->setLayoutRootPaths(['EXT:backend/Resources/Private/Layouts']);
         $this->view->getRequest()->setControllerExtensionName('Backend');
-        $this->view->assign('copyright', $this->copyright->getCopyrightNotice());
+        $this->view->assign('copyright', $this->typo3Information->getCopyrightNotice());
     }
 
     /**
index 923ee81..06c9452 100644 (file)
@@ -31,7 +31,7 @@ use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\FormProtection\BackendFormProtection;
 use TYPO3\CMS\Core\FormProtection\FormProtectionFactory;
 use TYPO3\CMS\Core\Http\HtmlResponse;
-use TYPO3\CMS\Core\Information\Typo3Copyright;
+use TYPO3\CMS\Core\Information\Typo3Information;
 use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Localization\Locales;
 use TYPO3\CMS\Core\Page\PageRenderer;
@@ -105,14 +105,14 @@ class LoginController implements LoggerAwareInterface
     protected $eventDispatcher;
 
     /**
-     * @var Typo3Copyright
+     * @var Typo3Information
      */
-    private $copyright;
+    private $typo3Information;
 
-    public function __construct(Typo3Copyright $copyright, EventDispatcherInterface $eventDispatcher)
+    public function __construct(Typo3Information $typo3Information, EventDispatcherInterface $eventDispatcher)
     {
+        $this->typo3Information = $typo3Information;
         $this->eventDispatcher = $eventDispatcher;
-        $this->copyright = $copyright;
     }
 
     /**
@@ -293,7 +293,7 @@ class LoginController implements LoggerAwareInterface
                 'capslock' => $this->getUriForFileName('EXT:backend/Resources/Public/Images/icon_capslock.svg'),
                 'typo3' => $this->getUriForFileName('EXT:backend/Resources/Public/Images/typo3_orange.svg'),
             ],
-            'copyright' => $this->copyright->getCopyrightNotice(),
+            'copyright' => $this->typo3Information->getCopyrightNotice(),
             'redirectUrl' => $this->redirectUrl,
             'loginRefresh' => $this->loginRefresh,
             'loginNewsItems' => $this->getSystemNews(),
index d4da9d2..6d530a1 100644 (file)
@@ -23,6 +23,7 @@ use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Imaging\IconFactory;
+use TYPO3\CMS\Core\Information\Typo3Information;
 use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Page\PageRenderer;
 use TYPO3\CMS\Core\Service\MarkerBasedTemplateService;
@@ -630,7 +631,7 @@ function jumpToUrl(URL) {
      */
     public function generator()
     {
-        return 'TYPO3 CMS, ' . TYPO3_URL_GENERAL . ', &#169; Kasper Sk&#229;rh&#248;j ' . TYPO3_copyright_year . ', extensions are copyright of their respective owners.';
+        return GeneralUtility::makeInstance(Typo3Information::class)->getHtmlGeneratorTagContent();
     }
 
     /*****************************************
index 4879948..da70f08 100644 (file)
@@ -39,7 +39,7 @@ use TYPO3\CMS\Core\Http\Uri;
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Imaging\IconFactory;
 use TYPO3\CMS\Core\Imaging\ImageManipulation\CropVariantCollection;
-use TYPO3\CMS\Core\Information\Typo3Copyright;
+use TYPO3\CMS\Core\Information\Typo3Information;
 use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Log\LogManager;
 use TYPO3\CMS\Core\Resource\ProcessedFile;
@@ -3824,8 +3824,8 @@ class BackendUtility
      */
     public static function TYPO3_copyRightNotice()
     {
-        trigger_error('BackendUtility::TYPO3_copyRightNotice() will be removed in TYPO3 v11.0, use the Typo3Copyright PHP class instead.', E_USER_DEPRECATED);
-        $copyrightGenerator = GeneralUtility::makeInstance(Typo3Copyright::class, static::getLanguageService());
+        trigger_error('BackendUtility::TYPO3_copyRightNotice() will be removed in TYPO3 v11.0, use the Typo3Information PHP class instead.', E_USER_DEPRECATED);
+        $copyrightGenerator = GeneralUtility::makeInstance(Typo3Information::class, static::getLanguageService());
         return $copyrightGenerator->getCopyrightNotice();
     }
 
index 3bbb942..5864d49 100644 (file)
@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Core\Controller;
  */
 
 use TYPO3\CMS\Core\Core\Environment;
+use TYPO3\CMS\Core\Information\Typo3Information;
 use TYPO3\CMS\Core\Messaging\AbstractMessage;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\PathUtility;
@@ -79,11 +80,11 @@ class ErrorPageController
         $this->view->assign('severity', $this->severity);
         $this->view->assign('message', $message);
         $this->view->assign('title', $title);
-        $this->view->assign('errorCodeUrlPrefix', TYPO3_URL_EXCEPTION);
+        $this->view->assign('errorCodeUrlPrefix', Typo3Information::URL_EXCEPTION);
         $this->view->assign('errorCode', $errorCode);
         $this->view->assign('logo', PathUtility::getAbsoluteWebPath(Environment::getFrameworkBasePath() . '/backend/Resources/Public/Images/typo3_orange.svg'));
         $this->view->assign('cssFile', PathUtility::getAbsoluteWebPath(Environment::getFrameworkBasePath() . '/core/Resources/Public/Css/errorpage.css'));
-        $this->view->assign('copyrightYear', TYPO3_copyright_year);
+        $this->view->assign('copyrightYear', GeneralUtility::makeInstance(Typo3Information::class)->getCopyrightYear());
         return $this->view->render();
     }
 }
index ba65404..ddc84c9 100644 (file)
@@ -100,19 +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_copyright_year')) {
+        if (defined('FILE_DENY_PATTERN_DEFAULT')) {
             return;
         }
 
-        define('TYPO3_copyright_year', '1998-' . date('Y'));
-
-        // TYPO3 external links
-        define('TYPO3_URL_GENERAL', 'https://typo3.org/');
-        define('TYPO3_URL_LICENSE', 'https://typo3.org/typo3-cms/overview/licenses/');
-        define('TYPO3_URL_EXCEPTION', 'https://typo3.org/go/exception/CMS/');
-        define('TYPO3_URL_DONATE', 'https://typo3.org/community/contribute/donate/');
-        define('TYPO3_URL_WIKI_OPCODECACHE', 'https://wiki.typo3.org/Opcode_Cache');
-
         // A linefeed, a carriage return, a CR-LF combination
         defined('LF') ?: define('LF', chr(10));
         defined('CR') ?: define('CR', chr(13));
@@ -127,6 +118,31 @@ class SystemEnvironmentBuilder
         if (!defined('TYPO3_mainDir')) {
             define('TYPO3_mainDir', 'typo3/');
         }
+
+        /**
+         * @deprecated use Typo3Information class to retrieve this information, will be removed in TYPO3 v11.0
+         */
+        define('TYPO3_copyright_year', '1998-' . date('Y'));
+        /**
+         * @deprecated use Typo3Information class to retrieve this information, will be removed in TYPO3 v11.0
+         */
+        define('TYPO3_URL_GENERAL', 'https://typo3.org/');
+        /**
+         * @deprecated use Typo3Information class to retrieve this information, will be removed in TYPO3 v11.0
+         */
+        define('TYPO3_URL_LICENSE', 'https://typo3.org/typo3-cms/overview/licenses/');
+        /**
+         * @deprecated use Typo3Information class to retrieve this information, will be removed in TYPO3 v11.0
+         */
+        define('TYPO3_URL_EXCEPTION', 'https://typo3.org/go/exception/CMS/');
+        /**
+         * @deprecated use Typo3Information class to retrieve this information, will be removed in TYPO3 v11.0
+         */
+        define('TYPO3_URL_DONATE', 'https://typo3.org/community/contribute/donate/');
+        /**
+         * @deprecated use Typo3Information class to retrieve this information, will be removed in TYPO3 v11.0
+         */
+        define('TYPO3_URL_WIKI_OPCODECACHE', 'https://wiki.typo3.org/Opcode_Cache');
     }
 
     /**
index d0ceab6..f7d05d6 100644 (file)
@@ -15,6 +15,8 @@ namespace TYPO3\CMS\Core\Error;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Information\Typo3Information;
+
 /**
  * A basic but solid exception handler which catches everything which
  * falls through the other exception handlers and provides useful debugging
@@ -95,7 +97,7 @@ HTML;
 
         $exceptionInfo = '';
         if ($throwable->getCode() > 0) {
-            $wikiLink = TYPO3_URL_EXCEPTION . 'debug/' . $throwable->getCode();
+            $wikiLink = Typo3Information::URL_EXCEPTION . 'debug/' . $throwable->getCode();
             $exceptionInfo = <<<INFO
             <div class="container">
                 <div class="callout">
diff --git a/typo3/sysext/core/Classes/Information/Typo3Copyright.php b/typo3/sysext/core/Classes/Information/Typo3Copyright.php
deleted file mode 100644 (file)
index 857738a..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-<?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!
- */
-
-use Psr\Http\Message\UriInterface;
-use TYPO3\CMS\Core\Http\Uri;
-use TYPO3\CMS\Core\Localization\LanguageService;
-use TYPO3\CMS\Core\Utility\GeneralUtility;
-
-class Typo3Copyright
-{
-    /**
-     * @var LanguageService
-     */
-    protected $languageService;
-
-    public function __construct(LanguageService $languageService = null)
-    {
-        if ($languageService) {
-            $this->languageService = $languageService;
-        } elseif ($GLOBALS['LANG'] instanceof LanguageService) {
-            $this->languageService = $GLOBALS['LANG'];
-        } else {
-            $this->languageService = GeneralUtility::makeInstance(LanguageService::class);
-            $this->languageService->init('default');
-        }
-    }
-
-    public function getCopyrightYear(): string
-    {
-        return TYPO3_copyright_year;
-    }
-
-    public function getCommunityWebsiteUrl(): UriInterface
-    {
-        return new Uri(TYPO3_URL_GENERAL);
-    }
-
-    public function getLicenseUrl(): UriInterface
-    {
-        return new Uri(TYPO3_URL_LICENSE);
-    }
-
-    /**
-     * Prints TYPO3 Copyright notice for About Modules etc. modules.
-     *
-     * Warning:
-     * DO NOT prevent this notice from being shown in ANY WAY.
-     * According to the GPL license an interactive application must show such a notice on start-up
-     * ('If the program is interactive, make it output a short notice... ' - see GPL.txt)
-     * Therefore preventing this notice from being properly shown is a violation of the license, regardless of whether
-     * you remove it or use a stylesheet to obstruct the display.
-     *
-     * @return string Text/Image (HTML) for copyright notice.
-     */
-    public function getCopyrightNotice(): string
-    {
-        // Copyright Notice
-        $loginCopyrightWarrantyProvider = strip_tags(trim($GLOBALS['TYPO3_CONF_VARS']['SYS']['loginCopyrightWarrantyProvider']));
-        $loginCopyrightWarrantyURL = strip_tags(trim($GLOBALS['TYPO3_CONF_VARS']['SYS']['loginCopyrightWarrantyURL']));
-
-        if (strlen($loginCopyrightWarrantyProvider) >= 2 && strlen($loginCopyrightWarrantyURL) >= 10) {
-            $warrantyNote = sprintf(
-                $this->languageService->sL('LLL:EXT:backend/Resources/Private/Language/locallang_login.xlf:warranty.by'),
-                htmlspecialchars($loginCopyrightWarrantyProvider),
-                '<a href="' . htmlspecialchars($loginCopyrightWarrantyURL) . '" target="_blank" rel="noreferrer">',
-                '</a>'
-            );
-        } else {
-            $warrantyNote = sprintf(
-                $this->languageService->sL('LLL:EXT:backend/Resources/Private/Language/locallang_login.xlf:no.warranty'),
-                '<a href="' . htmlspecialchars((string)$this->getLicenseUrl()) . '" target="_blank" rel="noreferrer">',
-                '</a>'
-            );
-        }
-        return '<a href="' . htmlspecialchars((string)$this->getCommunityWebsiteUrl()) . '" target="_blank" rel="noreferrer">' .
-            $this->languageService->sL('LLL:EXT:backend/Resources/Private/Language/locallang_login.xlf:typo3.cms') . '</a>. ' .
-            $this->languageService->sL('LLL:EXT:backend/Resources/Private/Language/locallang_login.xlf:copyright') . ' &copy; '
-            . htmlspecialchars($this->getCopyrightYear()) . ' Kasper Sk&aring;rh&oslash;j. ' .
-            $this->languageService->sL('LLL:EXT:backend/Resources/Private/Language/locallang_login.xlf:extension.copyright') . ' ' .
-            sprintf(
-                $this->languageService->sL('LLL:EXT:backend/Resources/Private/Language/locallang_login.xlf:details.link'),
-                '<a href="' . htmlspecialchars((string)$this->getCommunityWebsiteUrl()) . '" target="_blank" rel="noreferrer">' . htmlspecialchars((string)$this->getCommunityWebsiteUrl()) . '</a>'
-            ) . ' ' .
-            strip_tags($warrantyNote, '<a>') . ' ' .
-            sprintf(
-                $this->languageService->sL('LLL:EXT:backend/Resources/Private/Language/locallang_login.xlf:free.software'),
-                '<a href="' . htmlspecialchars((string)$this->getLicenseUrl()) . '" target="_blank" rel="noreferrer">',
-                '</a> '
-            )
-            . $this->languageService->sL('LLL:EXT:backend/Resources/Private/Language/locallang_login.xlf:keep.notice');
-    }
-}
diff --git a/typo3/sysext/core/Classes/Information/Typo3Information.php b/typo3/sysext/core/Classes/Information/Typo3Information.php
new file mode 100644 (file)
index 0000000..3d65879
--- /dev/null
@@ -0,0 +1,127 @@
+<?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!
+ */
+
+use TYPO3\CMS\Core\Localization\LanguageService;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+
+/**
+ * Contains information and links, or copyright information for the project.
+ */
+class Typo3Information
+{
+    public const URL_COMMUNITY = 'https://typo3.org/';
+    public const URL_LICENSE = 'https://typo3.org/typo3-cms/overview/licenses/';
+    public const URL_EXCEPTION = 'https://typo3.org/go/exception/CMS/';
+    public const URL_DONATE = 'https://typo3.org/community/contribute/donate/';
+    public const URL_OPCACHE = 'https://wiki.typo3.org/Opcode_Cache';
+
+    /**
+     * @var LanguageService
+     */
+    protected $languageService;
+
+    public function __construct(LanguageService $languageService = null)
+    {
+        if ($languageService) {
+            $this->languageService = $languageService;
+        } elseif ($GLOBALS['LANG'] instanceof LanguageService) {
+            $this->languageService = $GLOBALS['LANG'];
+        } else {
+            $this->languageService = GeneralUtility::makeInstance(LanguageService::class);
+            $this->languageService->init('default');
+        }
+    }
+
+    public function getCopyrightYear(): string
+    {
+        return '1998-' . date('Y');
+    }
+
+    /**
+     * Used for any backend rendering in the <meta generator> tag when rendering HTML.
+     *
+     * @return string
+     */
+    public function getHtmlGeneratorTagContent(): string
+    {
+        return 'TYPO3 CMS, ' . static::URL_COMMUNITY . ', &#169; Kasper Sk&#229;rh&#248;j ' . $this->getCopyrightYear() . ', extensions are copyright of their respective owners.';
+    }
+
+    /**
+     * Used for any frontend rendering in the <head> tag when rendering HTML.
+     *
+     * @return string
+     */
+    public function getInlineHeaderComment(): string
+    {
+        return '       This website is powered by TYPO3 - inspiring people to share!
+       TYPO3 is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.
+       TYPO3 is copyright ' . $this->getCopyrightYear() . ' of Kasper Skaarhoj. Extensions are copyright of their respective owners.
+       Information and contribution at ' . static::URL_COMMUNITY . '
+';
+    }
+
+    /**
+     * Prints TYPO3 Copyright notice for About Modules etc. modules.
+     *
+     * Warning:
+     * DO NOT prevent this notice from being shown in ANY WAY.
+     * According to the GPL license an interactive application must show such a notice on start-up
+     * ('If the program is interactive, make it output a short notice... ' - see GPL.txt)
+     * Therefore preventing this notice from being properly shown is a violation of the license, regardless of whether
+     * you remove it or use a stylesheet to obstruct the display.
+     *
+     * @return string Text/Image (HTML) for copyright notice.
+     */
+    public function getCopyrightNotice(): string
+    {
+        // Copyright Notice
+        $loginCopyrightWarrantyProvider = strip_tags(trim($GLOBALS['TYPO3_CONF_VARS']['SYS']['loginCopyrightWarrantyProvider']));
+        $loginCopyrightWarrantyURL = strip_tags(trim($GLOBALS['TYPO3_CONF_VARS']['SYS']['loginCopyrightWarrantyURL']));
+
+        if (strlen($loginCopyrightWarrantyProvider) >= 2 && strlen($loginCopyrightWarrantyURL) >= 10) {
+            $warrantyNote = sprintf(
+                $this->languageService->sL('LLL:EXT:backend/Resources/Private/Language/locallang_login.xlf:warranty.by'),
+                htmlspecialchars($loginCopyrightWarrantyProvider),
+                '<a href="' . htmlspecialchars($loginCopyrightWarrantyURL) . '" target="_blank" rel="noreferrer">',
+                '</a>'
+            );
+        } else {
+            $warrantyNote = sprintf(
+                $this->languageService->sL('LLL:EXT:backend/Resources/Private/Language/locallang_login.xlf:no.warranty'),
+                '<a href="' . htmlspecialchars(static::URL_LICENSE) . '" target="_blank" rel="noreferrer">',
+                '</a>'
+            );
+        }
+        return '<a href="' . htmlspecialchars(static::URL_COMMUNITY) . '" target="_blank" rel="noreferrer">' .
+            $this->languageService->sL('LLL:EXT:backend/Resources/Private/Language/locallang_login.xlf:typo3.cms') . '</a>. ' .
+            $this->languageService->sL('LLL:EXT:backend/Resources/Private/Language/locallang_login.xlf:copyright') . ' &copy; '
+            . htmlspecialchars($this->getCopyrightYear()) . ' Kasper Sk&aring;rh&oslash;j. ' .
+            $this->languageService->sL('LLL:EXT:backend/Resources/Private/Language/locallang_login.xlf:extension.copyright') . ' ' .
+            sprintf(
+                $this->languageService->sL('LLL:EXT:backend/Resources/Private/Language/locallang_login.xlf:details.link'),
+                '<a href="' . htmlspecialchars(static::URL_COMMUNITY) . '" target="_blank" rel="noreferrer">' . htmlspecialchars(static::URL_COMMUNITY) . '</a>'
+            ) . ' ' .
+            strip_tags($warrantyNote, '<a>') . ' ' .
+            sprintf(
+                $this->languageService->sL('LLL:EXT:backend/Resources/Private/Language/locallang_login.xlf:free.software'),
+                '<a href="' . htmlspecialchars(static::URL_LICENSE) . '" target="_blank" rel="noreferrer">',
+                '</a> '
+            )
+            . $this->languageService->sL('LLL:EXT:backend/Resources/Private/Language/locallang_login.xlf:keep.notice');
+    }
+}
index e568222..36cf715 100644 (file)
@@ -11,7 +11,7 @@ Description
 
 The PHP method :php:`TYPO3\CMS\Backend\Utility\BackendUtility::TYPO3_copyRightNotice` that is
 used to display information about the warranty and copyright of the product, e.g. used in the
-login screen, has been superseded by a new API :php:`TYPO3\CMS\Core\Information\Typo3Copyright`.
+login screen, has been superseded by a new API :php:`TYPO3\CMS\Core\Information\Typo3Information`.
 
 The existing static method has been marked as deprecated.
 
@@ -34,6 +34,6 @@ if you are affected.
 Migration
 =========
 
-Use the new :php:`Typo3Copyright` PHP class, and its method :php:`getCopyrightNotice()` which will return the same output.
+Use the new :php:`Typo3Information` PHP class, and its method :php:`getCopyrightNotice()` which will return the same output.
 
 .. index:: PHP-API, FullyScanned, ext:backend
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-89866-Global-TYPO3-information-related-constants.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-89866-Global-TYPO3-information-related-constants.rst
new file mode 100644 (file)
index 0000000..6fddc9f
--- /dev/null
@@ -0,0 +1,53 @@
+.. include:: ../../Includes.txt
+
+================================================================
+Deprecation: #89866 - Global TYPO3-information related constants
+================================================================
+
+See :issue:`89866`
+
+Description
+===========
+
+The following global constants, which are initialized at the very
+beginning of each TYPO3-related PHP process, have been deprecated:
+
+* :php:`TYPO3_copyright_year`
+* :php:`TYPO3_URL_GENERAL`
+* :php:`TYPO3_URL_LICENSE`
+* :php:`TYPO3_URL_EXCEPTION`
+* :php:`TYPO3_URL_DONATE`
+* :php:`TYPO3_URL_WIKI_OPCODECACHE`
+
+They have been migrated to the PHP class :php:`TYPO3\CMS\Core\Information\Typo3Information`
+in order to benefit from opcaching, and to exactly reference when they are used
+and where they are used throughout TYPO3.
+
+This allows for further optimizations during the Bootstrap process and in our
+testing suites.
+
+In addition, the new PHP class encapsulates all global TYPO3-information and
+community-wide information in one place.
+
+
+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
+======================
+
+Any TYPO3 installation with a custom extension that uses these
+constants directly, which is highly unlikely.
+
+
+Migration
+=========
+
+Use the public class constants or the public methods of the
+new PHP class :php:`TYPO3\CMS\Core\Information\Typo3Information` directly.
+
+.. index:: PHP-API, FullyScanned, ext:core
index 57de288..3086e18 100644 (file)
@@ -21,6 +21,8 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
  */
 class ProductionExceptionHandlerTest extends UnitTestCase
 {
+    protected $resetSingletonInstances = true;
+
     /**
      * @var \TYPO3\CMS\Core\Error\ProductionExceptionHandler|\PHPUnit\Framework\MockObject\MockObject
      */
index 5618319..0df74fa 100644 (file)
@@ -23,6 +23,7 @@ use Psr\Http\Server\RequestHandlerInterface;
 use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Http\NullResponse;
 use TYPO3\CMS\Core\Http\Response;
+use TYPO3\CMS\Core\Information\Typo3Information;
 use TYPO3\CMS\Core\Page\PageRenderer;
 use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
 use TYPO3\CMS\Core\TimeTracker\TimeTracker;
@@ -374,11 +375,7 @@ class RequestHandler implements RequestHandlerInterface
         $pageRenderer->setHeadTag($headTag);
         // Setting charset meta tag:
         $pageRenderer->setCharSet($theCharset);
-        $pageRenderer->addInlineComment('      This website is powered by TYPO3 - inspiring people to share!
-       TYPO3 is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.
-       TYPO3 is copyright ' . TYPO3_copyright_year . ' of Kasper Skaarhoj. Extensions are copyright of their respective owners.
-       Information and contribution at ' . TYPO3_URL_GENERAL . '
-');
+        $pageRenderer->addInlineComment(GeneralUtility::makeInstance(Typo3Information::class)->getInlineHeaderComment());
         if ($controller->baseUrl) {
             $pageRenderer->setBaseUrl($controller->baseUrl);
         }
index bed3cab..84479ff 100644 (file)
@@ -24,6 +24,8 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
  */
 class ErrorControllerTest extends UnitTestCase
 {
+    protected $resetSingletonInstances = true;
+
     /**
      * @test
      */
index 49ef542..ea89ba4 100644 (file)
@@ -36,6 +36,8 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
  */
 class RequestHandlerTest extends UnitTestCase
 {
+    protected $resetSingletonInstances = true;
+
     public function generateHtmlTagIncludesAllPossibilitiesDataProvider()
     {
         return [
index e7a60bc..005d3c6 100644 (file)
@@ -32,8 +32,10 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 class PageArgumentValidatorTest extends UnitTestCase
 {
+    protected $resetSingletonInstances = true;
+
     /**
-     * @var CacheHashCaluclator
+     * @var CacheHashCalculator
      */
     protected $cacheHashCalculator;
 
@@ -56,7 +58,7 @@ class PageArgumentValidatorTest extends UnitTestCase
     {
         parent::setUp();
         $this->timeTrackerStub = new TimeTracker(false);
-        $this->cacheHashCalculator = new CacheHashCalculator;
+        $this->cacheHashCalculator = new CacheHashCalculator();
 
         // A request handler which only runs through
         $this->responseOutputHandler = new class implements RequestHandlerInterface {
index 5c7ab24..0807428 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Install\SystemEnvironment;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Information\Typo3Information;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\Messaging\FlashMessageQueue;
 
@@ -609,7 +610,7 @@ class Check implements CheckInterface
                     . '* The PHP extension eaccelerator is known to break this if'
                     . ' it is compiled without --with-eaccelerator-doc-comment-inclusion flag.'
                     . ' This compile flag must be specified, otherwise TYPO3 CMS will not work.' . LF
-                    . 'For more information take a look in our wiki ' . TYPO3_URL_WIKI_OPCODECACHE . '.',
+                    . 'For more information take a look in our wiki ' . Typo3Information::URL_OPCACHE . '.',
                 'PHP Doc comment reflection broken',
                 FlashMessage::ERROR
             ));
index dc958a8..90b8dda 100644 (file)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Install\SystemEnvironment;
  */
 
 use TYPO3\CMS\Core\Core\Environment;
+use TYPO3\CMS\Core\Information\Typo3Information;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\Messaging\FlashMessageQueue;
 use TYPO3\CMS\Core\Service\OpcodeCacheService;
@@ -192,7 +193,7 @@ class SetupCheck implements CheckInterface
     protected function checkSomePhpOpcodeCacheIsLoaded()
     {
         // Link to our wiki page, so we can update opcode cache issue information independent of TYPO3 CMS releases.
-        $wikiLink = 'For more information take a look in our wiki ' . TYPO3_URL_WIKI_OPCODECACHE . '.';
+        $wikiLink = 'For more information take a look in our wiki ' . Typo3Information::URL_OPCACHE . '.';
         $opcodeCaches = GeneralUtility::makeInstance(OpcodeCacheService::class)->getAllActive();
         if (empty($opcodeCaches)) {
             // Set status to notice. It needs to be notice so email won't be triggered.
index b61d9e1..cc0f006 100644 (file)
@@ -190,4 +190,34 @@ return [
             'Deprecation-90007-GlobalConstantsTYPO3_versionAndTYPO3_branch.rst'
         ]
     ],
+    'TYPO3_copyright_year' => [
+        'restFiles' => [
+            'Deprecation-89866-Global-TYPO3-information-related-constants.rst'
+        ]
+    ],
+    'TYPO3_URL_GENERAL' => [
+        'restFiles' => [
+            'Deprecation-89866-Global-TYPO3-information-related-constants.rst'
+        ]
+    ],
+    'TYPO3_URL_LICENSE' => [
+        'restFiles' => [
+            'Deprecation-89866-Global-TYPO3-information-related-constants.rst'
+        ]
+    ],
+    'TYPO3_URL_EXCEPTION' => [
+        'restFiles' => [
+            'Deprecation-89866-Global-TYPO3-information-related-constants.rst'
+        ]
+    ],
+    'TYPO3_URL_DONATE' => [
+        'restFiles' => [
+            'Deprecation-89866-Global-TYPO3-information-related-constants.rst'
+        ]
+    ],
+    'TYPO3_URL_WIKI_OPCODECACHE' => [
+        'restFiles' => [
+            'Deprecation-89866-Global-TYPO3-information-related-constants.rst'
+        ]
+    ],
 ];
index c4c362b..fb4f22b 100644 (file)
@@ -23,6 +23,7 @@ use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\Exception\SiteNotFoundException;
 use TYPO3\CMS\Core\Http\HtmlResponse;
+use TYPO3\CMS\Core\Information\Typo3Information;
 use TYPO3\CMS\Core\Routing\InvalidRouteArgumentsException;
 use TYPO3\CMS\Core\Routing\UnableToLinkToPageException;
 use TYPO3\CMS\Core\Site\SiteFinder;
@@ -187,7 +188,7 @@ class PreviewController
         $this->moduleTemplate->getPageRenderer()->addInlineSetting('Workspaces', 'id', $this->pageId);
 
         $this->view->assignMultiple([
-            'logoLink' => TYPO3_URL_GENERAL,
+            'logoLink' => Typo3Information::URL_COMMUNITY,
             'liveUrl' => $liveUrl ?? false,
             'wsUrl' => $wsUrl,
             'wsSettingsUrl' => $wsSettingsUrl,