From d9b8eea8648f1152cb55024348697857008ce643 Mon Sep 17 00:00:00 2001 From: Benni Mack <benni@typo3.org> Date: Thu, 2 Apr 2020 22:45:29 +0200 Subject: [PATCH] [TASK] Deprecate various hooks in ContentObjectRenderer The following hooks within ContentObjectRenderer have been marked as deprecated: * $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClass'] * $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClassDefault'] Both concepts have been superseded in TYPO3 v6 with custom cObjects via $GLOBALS['TYPO3_CONF_VARS']['FE']['ContentObjects'] * $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['extLinkATagParamsHandler'] * cObj->extLinkATagParams() is now also marked as internal, as it serves no purpose anymore once the hook gets removed. In addition * $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['typolinkLinkHandler'] is deprecated since the initial addition of LinkHandler APIs in TYPO3 v8. Resolves: #90937 Releases: master Change-Id: Iaa1ea741f0bfef472f51a8067d5cea2f9ffcb774 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/64055 Tested-by: Georg Ringer <georg.ringer@gmail.com> Tested-by: TYPO3com <noreply@typo3.com> Tested-by: Susanne Moog <look@susi.dev> Reviewed-by: Georg Ringer <georg.ringer@gmail.com> Reviewed-by: Susanne Moog <look@susi.dev> --- ...37-VariousHooksInContentObjectRenderer.rst | 46 +++++++++++++++++++ .../ContentObjectGetSingleHookInterface.php | 2 + .../ContentObject/ContentObjectRenderer.php | 10 ++++ .../Php/ArrayDimensionMatcher.php | 20 ++++++++ .../ExtensionScanner/Php/ClassNameMatcher.php | 5 ++ 5 files changed, 83 insertions(+) create mode 100644 typo3/sysext/core/Documentation/Changelog/master/Deprecation-90937-VariousHooksInContentObjectRenderer.rst diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-90937-VariousHooksInContentObjectRenderer.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-90937-VariousHooksInContentObjectRenderer.rst new file mode 100644 index 000000000000..75b6518a20a4 --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-90937-VariousHooksInContentObjectRenderer.rst @@ -0,0 +1,46 @@ +.. include:: ../../Includes.txt + +============================================================ +Deprecation: #90937 - Various hooks in ContentObjectRenderer +============================================================ + +See :issue:`90937` + +Description +=========== + +The following hooks within ContentObjectRenderer have been deprecated: + +* $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClass'] +* $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClassDefault'] +* $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['extLinkATagParamsHandler'] +* $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['typolinkLinkHandler'] + +All hooks have been available for a long time, and several new concepts and APIs that have been added in previous LTS versions already superseded the hooks. + + +Impact +====== + +Extensions registering the hook will trigger a PHP deprecation notice when one of the mentioned hooks when the code is executed. + + +Affected Installations +====================== + +TYPO3 installations with older extensions implementing one of the hooks above, which is very rare and only serve specific use-cases +for rendering ContentObjects or custom link style tags that are not related to TYPO3 v8 linking syntax (`t3://...`). + + +Migration +========= + +The hooks `cObjTypeAndClass` and `cObjTypeAndClassDefault` can be simplified by using the new way of registering custom ContentObjects via: + +:php:`$GLOBALS['TYPO3_CONF_VARS']['FE']['ContentObjects']` - see `EXT:frontend/ext_localconf.php` for examples - TYPO3 Core adds its shipped ContentObjects exactly the same way. + +The `typolinkLinkHandler` hook is used for registering custom link syntax that start with a certain keyword such as "news:13". + +Since TYPO3 v8, LinkHandler support has been added to TYPO3 Core natively, using the new `t3://` syntax. The "LinkHandler" registry can be extended via :php:`$GLOBALS['TYPO3_CONF_VARS']['SYS']['linkHandler']` and :php:`$GLOBALS['TYPO3_CONF_VARS']['FE']['typolinkBuilder']` that serves the same purpose with a better API. + +.. index:: Frontend, FullyScanned, ext:frontend \ No newline at end of file diff --git a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectGetSingleHookInterface.php b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectGetSingleHookInterface.php index 0ee7f9d4dda9..e1274d45d5fa 100644 --- a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectGetSingleHookInterface.php +++ b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectGetSingleHookInterface.php @@ -16,6 +16,8 @@ namespace TYPO3\CMS\Frontend\ContentObject; /** * Interface for classes which hook into \TYPO3\CMS\Frontend\ContentObject and do additional cObjGetSingle processing + * + * @deprecated will be removed in TYPO3 v11, as this functionality has been moved into `$GLOBALS['TYPO3_CONF_VARS']['FE']['ContentObjects']` */ interface ContentObjectGetSingleHookInterface { diff --git a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php index 541cce5db5f9..1fb87f1db8e1 100644 --- a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php +++ b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php @@ -392,11 +392,13 @@ class ContentObjectRenderer implements LoggerAwareInterface * Additionally registered content object types and class names * * @var array + * @deprecated - will be removed in TYPO3 v11.0 */ protected $cObjHookObjectsRegistry = []; /** * @var array + * @deprecated - will be removed in TYPO3 v11.0 */ public $cObjHookObjectsArr = []; @@ -565,6 +567,7 @@ class ContentObjectRenderer implements LoggerAwareInterface : ''; $this->parameters = []; foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClass'] ?? [] as $classArr) { + trigger_error('The hook $TYPO3_CONF_VARS[SC_OPTIONS][tslib/class.tslib_content.php][cObjTypeAndClass] for adding custom cObjects will be removed in TYPO3 v11.0. Use a custom cObject which you can register directly instead.', E_USER_DEPRECATED); $this->cObjHookObjectsRegistry[$classArr[0]] = $classArr[1]; } $this->stdWrapHookObjects = []; @@ -721,6 +724,7 @@ class ContentObjectRenderer implements LoggerAwareInterface } else { $hooked = false; // Application defined cObjects + // @deprecated since TYPO3 v10.4 - will be removed in TYPO3 v11.0 if (!empty($this->cObjHookObjectsRegistry[$name])) { if (empty($this->cObjHookObjectsArr[$name])) { $this->cObjHookObjectsArr[$name] = GeneralUtility::makeInstance($this->cObjHookObjectsRegistry[$name]); @@ -738,6 +742,9 @@ class ContentObjectRenderer implements LoggerAwareInterface } else { // Call hook functions for extra processing if ($name) { + if (!empty($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClassDefault'])) { + trigger_error('The hook $TYPO3_CONF_VARS[SC_OPTIONS][tslib/class.tslib_content.php][cObjTypeAndClassDefault] for adding custom processing will be removed. Use a custom cObject which you can register directly instead.', E_USER_DEPRECATED); + } foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClassDefault'] ?? [] as $className) { $hookObject = GeneralUtility::makeInstance($className); if (!$hookObject instanceof ContentObjectGetSingleHookInterface) { @@ -1552,11 +1559,13 @@ class ContentObjectRenderer implements LoggerAwareInterface * @param string $URL URL of the website * @param string $TYPE * @return string The additional tag properties + * @internal This method will be removed as it serves no purpose anymore in TYPO3 v11.0 */ public function extLinkATagParams($URL, $TYPE) { $out = ''; if (!empty($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['extLinkATagParamsHandler'])) { + trigger_error('The hook $TYPO3_CONF_VARS[SC_OPTIONS][tslib/class.tslib_content.php][extLinkATagParamsHandler] will be removed in TYPO3 v11.0. Use a custom LinkHandler instead.', E_USER_DEPRECATED); $extLinkATagParamsHandler = GeneralUtility::makeInstance($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['extLinkATagParamsHandler']); if (method_exists($extLinkATagParamsHandler, 'main')) { $out .= trim($extLinkATagParamsHandler->main($URL, $TYPE, $this)); @@ -4963,6 +4972,7 @@ class ContentObjectRenderer implements LoggerAwareInterface if (!empty($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['typolinkLinkHandler'][$linkHandlerKeyword]) && (string)$linkHandlerValue !== '' ) { + trigger_error('The hook $TYPO3_CONF_VARS[SC_OPTIONS][tslib/class.tslib_content.php][typolinkLinkHandler] will be removed in TYPO3 v11.0. Use a custom LinkHandler instead. The used link handler keyword was: ' . $linkHandlerKeyword, E_USER_DEPRECATED); $linkHandlerObj = GeneralUtility::makeInstance($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['typolinkLinkHandler'][$linkHandlerKeyword]); if (method_exists($linkHandlerObj, 'main')) { return $linkHandlerObj->main($linkText, $configuration, $linkHandlerKeyword, $linkHandlerValue, $mixedLinkParameter, $this); diff --git a/typo3/sysext/install/Configuration/ExtensionScanner/Php/ArrayDimensionMatcher.php b/typo3/sysext/install/Configuration/ExtensionScanner/Php/ArrayDimensionMatcher.php index cd4427ccdf12..26c3acef6b4d 100644 --- a/typo3/sysext/install/Configuration/ExtensionScanner/Php/ArrayDimensionMatcher.php +++ b/typo3/sysext/install/Configuration/ExtensionScanner/Php/ArrayDimensionMatcher.php @@ -371,4 +371,24 @@ return [ 'Deprecation-88740-DeprecateFeloginPibasePlugin.rst', ], ], + '$GLOBALS[\'TYPO3_CONF_VARS\'][\'SC_OPTIONS\'][\'tslib/class.tslib_content.php\'][\'cObjTypeAndClass\']' => [ + 'restFiles' => [ + 'Deprecation-90937-VariousHooksInContentObjectRenderer.rst', + ], + ], + '$GLOBALS[\'TYPO3_CONF_VARS\'][\'SC_OPTIONS\'][\'tslib/class.tslib_content.php\'][\'cObjTypeAndClassDefault\']' => [ + 'restFiles' => [ + 'Deprecation-90937-VariousHooksInContentObjectRenderer.rst', + ], + ], + '$GLOBALS[\'TYPO3_CONF_VARS\'][\'SC_OPTIONS\'][\'tslib/class.tslib_content.php\'][\'extLinkATagParamsHandler\']' => [ + 'restFiles' => [ + 'Deprecation-90937-VariousHooksInContentObjectRenderer.rst', + ], + ], + '$GLOBALS[\'TYPO3_CONF_VARS\'][\'SC_OPTIONS\'][\'tslib/class.tslib_content.php\'][\'typolinkLinkHandler\']' => [ + 'restFiles' => [ + 'Deprecation-90937-VariousHooksInContentObjectRenderer.rst', + ], + ], ]; diff --git a/typo3/sysext/install/Configuration/ExtensionScanner/Php/ClassNameMatcher.php b/typo3/sysext/install/Configuration/ExtensionScanner/Php/ClassNameMatcher.php index eabc22a054db..8afba7fb77ee 100644 --- a/typo3/sysext/install/Configuration/ExtensionScanner/Php/ClassNameMatcher.php +++ b/typo3/sysext/install/Configuration/ExtensionScanner/Php/ClassNameMatcher.php @@ -1407,4 +1407,9 @@ return [ 'Deprecation-90692-DeprecateFileCollectionModels.rst', ], ], + 'TYPO3\CMS\Frontend\ContentObject\ContentObjectGetSingleHookInterface' => [ + 'restFiles' => [ + 'Deprecation-90937-VariousHooksInContentObjectRenderer.rst', + ], + ], ]; -- GitLab