diff --git a/typo3/sysext/core/Classes/Compatibility/PublicPropertyDeprecationTrait.php b/typo3/sysext/core/Classes/Compatibility/PublicPropertyDeprecationTrait.php index ea22cf2d176e8d1de7e1e845199dc40f2f28ee17..c2bd5e4d51acc6029e39679915c17f9521e0a504 100644 --- a/typo3/sysext/core/Classes/Compatibility/PublicPropertyDeprecationTrait.php +++ b/typo3/sysext/core/Classes/Compatibility/PublicPropertyDeprecationTrait.php @@ -42,10 +42,9 @@ namespace TYPO3\CMS\Core\Compatibility; * use PublicPropertyDeprecationTrait; * * /** - * * List previously publically accessible variables - * * @var array + * * List previously publicly accessible variables * *... - * private $deprecatedPublicProperties = [ + * private array $deprecatedPublicProperties = [ * 'myProperty' => 'Using myProperty is deprecated and will not be possible anymore in TYPO3 v10.0. Use getMyProperty() instead.' * ]; * diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-95219-TypoScriptFrontendController-ATagParams.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-95219-TypoScriptFrontendController-ATagParams.rst new file mode 100644 index 0000000000000000000000000000000000000000..1f73f1a572f3e60f1d7f9b8e23f8aaa4cb977eb9 --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-95219-TypoScriptFrontendController-ATagParams.rst @@ -0,0 +1,53 @@ +.. include:: ../../Includes.txt + +============================================================== +Deprecation: #95219 - TypoScriptFrontendController->ATagParams +============================================================== + +See :issue:`95219` + +Description +=========== + +The public property :php:`TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController->ATagParams` +has been marked as deprecated. + +It was used in the past as a copy of the value +:php:`TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController->config[config][ATagParams]`, +which should be used instead. + +There is no need to use such a (less prominent) configuration option in a +separate public property, as it needs to be kept in sync with the +actual configuration option. + +The second argument of the related method +:php:`TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer->getATagParams()` +called :php:`$addGlobal` is also marked as deprecated, and will have no effect +anymore in TYPO3 v12. + +Impact +====== + +Accessing, setting or writing this property will trigger a PHP deprecation +message. + +Calling :php:`TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer->getATagParams()` +with a second argument set to false will trigger a PHP deprecation message +as well. + + +Affected Installations +====================== + +TYPO3 installations with third-party-extensions accessing, or +writing this property directly within PHP, or calling :php:`getATagParams()` +directly, which is highly unlikely. + + +Migration +========= + +All calls of :php:`$GLOBALS['TSFE']->ATagParams` can be replaced +with :php:`$GLOBALS['TSFE']->config['config']['ATagParams'] ?? ''`. + +.. index:: Frontend, PHP-API, TypoScript, FullyScanned, ext:frontend diff --git a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php index 9dc5a9dd269858d139515a4db4645e96639820b7..d263621f703cd4991991b98927d6d90b3d25e345 100644 --- a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php +++ b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php @@ -1149,7 +1149,7 @@ class ContentObjectRenderer implements LoggerAwareInterface $a1 = sprintf( '<a %s%s>', GeneralUtility::implodeAttributes($attrs, true), - $this->getTypoScriptFrontendController()->ATagParams + trim($this->getTypoScriptFrontendController()->config['config']['ATagParams'] ?? '') ? ' ' . trim($this->getTypoScriptFrontendController()->config['config']['ATagParams']) : '' ); $a2 = '</a>'; $this->addDefaultFrontendJavaScript(); @@ -1188,15 +1188,20 @@ class ContentObjectRenderer implements LoggerAwareInterface * Uses the ATagParams property. * * @param array $conf TypoScript configuration properties - * @param bool|int $addGlobal If set, will add the global config.ATagParams to the link + * @param bool|int|null $addGlobal If set, will add the global config.ATagParams to the link. @deprecated will be removed in TYPO3 v12.0. * @return string String containing the parameters to the A tag (if non empty, with a leading space) * @see typolink() */ - public function getATagParams($conf, $addGlobal = 1) + public function getATagParams($conf, $addGlobal = null) { $aTagParams = ' ' . $this->stdWrapValue('ATagParams', $conf ?? []); - if ($addGlobal) { - $globalParams = $this->getTypoScriptFrontendController()->ATagParams ?? ''; + if ($addGlobal !== null) { + trigger_error('Setting the second argument $addGlobal of $cObj->getATagParams will have no effect in TYPO3 v12.0 anymore.', E_USER_DEPRECATED); + } + // Add the global config.ATagParams if $addGlobal is NULL (default) or set to TRUE. + // @deprecated The if clause can be removed in v12 + if ($addGlobal === null || $addGlobal) { + $globalParams = trim($this->getTypoScriptFrontendController()->config['config']['ATagParams'] ?? ''); $aTagParams = ' ' . trim($globalParams . $aTagParams); } // Extend params diff --git a/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php b/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php index 5647c1c78c5dece0e9b317a4456444b4c89ee71f..79448707b09a4fec7da25d263bf6b5d109fd9068 100644 --- a/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php +++ b/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php @@ -24,6 +24,7 @@ use TYPO3\CMS\Backend\FrontendBackendUserAuthentication; use TYPO3\CMS\Core\Cache\CacheManager; use TYPO3\CMS\Core\Charset\CharsetConverter; use TYPO3\CMS\Core\Charset\UnknownCharsetException; +use TYPO3\CMS\Core\Compatibility\PublicPropertyDeprecationTrait; use TYPO3\CMS\Core\Configuration\Loader\PageTsConfigLoader; use TYPO3\CMS\Core\Configuration\Parser\PageTsConfigParser; use TYPO3\CMS\Core\Context\Context; @@ -97,6 +98,13 @@ use TYPO3\CMS\Frontend\Resource\FilePathSanitizer; class TypoScriptFrontendController implements LoggerAwareInterface { use LoggerAwareTrait; + use PublicPropertyDeprecationTrait; + /** + * List previously publicly accessible variables + */ + private array $deprecatedPublicProperties = [ + 'ATagParams' => 'Using ATagParams will not be possible anymore in TYPO3 v12.0. Use TSFE->config[config][ATagParams] instead.' + ]; /** * The page id (int) @@ -371,8 +379,9 @@ class TypoScriptFrontendController implements LoggerAwareInterface /** * <A>-tag parameters * @var string + * @deprecated will be removed in TYPO3 v12.0. Use TSFE->config[config][ATagParams] directly. */ - public $ATagParams = ''; + protected $ATagParams = ''; /** * Search word regex, calculated if there has been search-words send. This is @@ -2478,6 +2487,7 @@ class TypoScriptFrontendController implements LoggerAwareInterface $this->absRefPrefix = GeneralUtility::getIndpEnv('TYPO3_SITE_PATH'); } } + // @deprecated. This line can be removed with TYPO3 v12.0. $this->ATagParams = trim($this->config['config']['ATagParams'] ?? '') ? ' ' . trim($this->config['config']['ATagParams']) : ''; $this->initializeSearchWordData($request->getParsedBody()['sword_list'] ?? $request->getQueryParams()['sword_list'] ?? null); // linkVars diff --git a/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php b/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php index b6db163c4b1889e4381931e509c61e8ca7a6a516..738cac3b2cc156f0808767796259ef208f1a37b7 100644 --- a/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php +++ b/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php @@ -1746,7 +1746,7 @@ class ContentObjectRendererTest extends UnitTestCase */ public function aTagParamsHaveSpaceBetweenLocalAndGlobalParams(): void { - $GLOBALS['TSFE']->ATagParams = 'data-global="dataglobal"'; + $GLOBALS['TSFE']->config['config']['ATagParams'] = 'data-global="dataglobal"'; $aTagParams = $this->subject->getATagParams(['ATagParams' => 'data-test="testdata"']); self::assertEquals(' data-global="dataglobal" data-test="testdata"', $aTagParams); } @@ -1757,7 +1757,7 @@ class ContentObjectRendererTest extends UnitTestCase public function aTagParamsHasNoLeadingSpaceIfEmpty(): void { // make sure global ATagParams are empty - $GLOBALS['TSFE']->ATagParams = ''; + $GLOBALS['TSFE']->config['config']['ATagParams'] = ''; $aTagParams = $this->subject->getATagParams(['ATagParams' => '']); self::assertEquals('', $aTagParams); } diff --git a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodArgumentDroppedMatcher.php b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodArgumentDroppedMatcher.php index 0edbf17f932729e227e99c0781301c8b193920e1..f19807b94be20f94f16643f25b5b1aa75c09c4e9 100644 --- a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodArgumentDroppedMatcher.php +++ b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodArgumentDroppedMatcher.php @@ -309,4 +309,10 @@ return [ 'Deprecation-95062-SkipSortingArgumentOfRelationHandler-writeForeignField.rst', ], ], + 'TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer->getATagParams' => [ + 'maximumNumberOfArguments' => 1, + 'restFiles' => [ + 'Deprecation-95219-TypoScriptFrontendController-ATagParams.rst', + ], + ], ]; diff --git a/typo3/sysext/install/Configuration/ExtensionScanner/Php/PropertyPublicMatcher.php b/typo3/sysext/install/Configuration/ExtensionScanner/Php/PropertyPublicMatcher.php index 058a902c5b517c4ae525c888f84d0958f45ebeaa..a93c25d7ecac7e5ffa1f72f2da865fc08b5c7c55 100644 --- a/typo3/sysext/install/Configuration/ExtensionScanner/Php/PropertyPublicMatcher.php +++ b/typo3/sysext/install/Configuration/ExtensionScanner/Php/PropertyPublicMatcher.php @@ -915,4 +915,9 @@ return [ 'Deprecation-95139-ExtbaseControllerContext.rst', ], ], + 'TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController->ATagParams' => [ + 'restFiles' => [ + 'Deprecation-95219-TypoScriptFrontendController-ATagParams.rst', + ], + ], ];