diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-85105-3rdMethodArgumentInPageRepository-getRootLine.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-85105-3rdMethodArgumentInPageRepository-getRootLine.rst new file mode 100644 index 0000000000000000000000000000000000000000..ad29a97787d21027b32ab96a74e95ce83a07fd2a --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-85105-3rdMethodArgumentInPageRepository-getRootLine.rst @@ -0,0 +1,37 @@ +.. include:: ../../Includes.txt + +========================================================================== +Deprecation: #85105 - 3rd method argument in PageRepository->getRootLine() +========================================================================== + +See :issue:`85105` + +Description +=========== + +The third argument of :php:`TYPO3\CMS\Frontend\Page\PageRepository->getRootLine()` has been marked +as deprecated. + +That argument was mainly used to catch exceptions when a faulty rootline is found. The PageRepository +currently handles the exceptions in a special way with some special magic. However, it is more +feasible to always throw an exception and have the caller handle possible exceptions. + + +Impact +====== + +Calling the method with three arguments will trigger a deprecation message. + + +Affected Installations +====================== + +TYPO3 installations with extensions calling the method directly with the 3rd argument. + + +Migration +========= + +Remove the third argument from code in PHP and wrap a try/catch block around the method call. + +.. index:: Frontend, PHP-API, FullyScanned \ No newline at end of file diff --git a/typo3/sysext/extbase/Classes/Configuration/BackendConfigurationManager.php b/typo3/sysext/extbase/Classes/Configuration/BackendConfigurationManager.php index 7782f9f09d23c63417f1f431fbe5c3f45403e33b..3f4b3fb3336cadb2bc604e128f401a63deb1a763 100644 --- a/typo3/sysext/extbase/Classes/Configuration/BackendConfigurationManager.php +++ b/typo3/sysext/extbase/Classes/Configuration/BackendConfigurationManager.php @@ -22,9 +22,9 @@ use TYPO3\CMS\Core\Type\Bitmask\Permission; use TYPO3\CMS\Core\TypoScript\TemplateService; use TYPO3\CMS\Core\Utility\ArrayUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Core\Utility\RootlineUtility; use TYPO3\CMS\Extbase\Mvc\Web\BackendRequestHandler; use TYPO3\CMS\Extbase\Mvc\Web\FrontendRequestHandler; -use TYPO3\CMS\Frontend\Page\PageRepository; /** * A general purpose configuration manager used in backend mode. @@ -62,10 +62,11 @@ class BackendConfigurationManager extends AbstractConfigurationManager // Get the root line $rootline = []; if ($pageId > 0) { - /** @var $sysPage PageRepository */ - $sysPage = GeneralUtility::makeInstance(PageRepository::class); - // Get the rootline for the current page - $rootline = $sysPage->getRootLine($pageId, '', true); + try { + $rootline = GeneralUtility::makeInstance(RootlineUtility::class, $pageId)->get(); + } catch (\RuntimeException $e) { + $rootline = []; + } } // This generates the constants/config + hierarchy info for the template. $template->runThroughTemplates($rootline, 0); diff --git a/typo3/sysext/frontend/Classes/Page/PageRepository.php b/typo3/sysext/frontend/Classes/Page/PageRepository.php index ce9ecca1b4cbcd8c6e3772b66149fa3cbfef70b2..a468b878adda5f849d1953d497cc4c731997bfff 100644 --- a/typo3/sysext/frontend/Classes/Page/PageRepository.php +++ b/typo3/sysext/frontend/Classes/Page/PageRepository.php @@ -955,8 +955,13 @@ class PageRepository implements LoggerAwareInterface * @return array Array with page records from the root line as values. The array is ordered with the outer records first and root record in the bottom. The keys are numeric but in reverse order. So if you traverse/sort the array by the numeric keys order you will get the order from root and out. If an error is found (like eternal looping or invalid mountpoint) it will return an empty array. * @see \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::getPageAndRootline() */ - public function getRootLine($uid, $MP = '', $ignoreMPerrors = false) + public function getRootLine($uid, $MP = '', $ignoreMPerrors = null) { + if ($ignoreMPerrors !== null) { + trigger_error('The third argument in PageRepository::getRootline() will be removed in TYPO3 v10.0. Use a try/catch block around this method to catch any mount point errors, if necessary', E_USER_DEPRECATED); + } else { + $ignoreMPerrors = false; + } $rootline = GeneralUtility::makeInstance(RootlineUtility::class, $uid, $MP, $this); try { return $rootline->get(); diff --git a/typo3/sysext/frontend/Classes/Typolink/PageLinkBuilder.php b/typo3/sysext/frontend/Classes/Typolink/PageLinkBuilder.php index a5ba1c59268ffd910ebbd257e4f701c6afb264eb..8061c4b86c76e4a91f95c1ea29064e0f3ce9ec7e 100644 --- a/typo3/sysext/frontend/Classes/Typolink/PageLinkBuilder.php +++ b/typo3/sysext/frontend/Classes/Typolink/PageLinkBuilder.php @@ -287,7 +287,11 @@ class PageLinkBuilder extends AbstractTypolinkBuilder // Find closest mount point // Gets rootline of linked-to page - $tCR_rootline = $tsfe->sys_page->getRootLine($pageId, '', true); + try { + $tCR_rootline = $tsfe->sys_page->getRootLine($pageId); + } catch (\RuntimeException $e) { + $tCR_rootline = []; + } $inverseTmplRootline = array_reverse($tsfe->tmpl->rootLine); $rl_mpArray = []; $startMPaccu = false; diff --git a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodArgumentDroppedMatcher.php b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodArgumentDroppedMatcher.php index f88110880e4055df321bc24097a7df547e2e6697..e2472dfdfa69ff566fd06a25ffaafed5c7575a35 100644 --- a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodArgumentDroppedMatcher.php +++ b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodArgumentDroppedMatcher.php @@ -177,4 +177,10 @@ return [ 'Breaking-84877-MethodsOfLocalizationRepositoryChanged.rst', ], ], + 'TYPO3\CMS\Frontend\Page\PageRepository->getRootLine' => [ + 'maximumNumberOfArguments' => 2, + 'restFiles' => [ + 'Deprecation-85105-3rdMethodArgumentInPageRepository-getRootLine.rst', + ], + ], ];