Skip to content

Commit 32c3376

Browse files
committed
[TASK] Remove further TSFE properties
The patch continues removing properties from TypoScriptFrontendController. We however keep one particular API: TypoScript stdWrap .data (Data / getText) implemented in ContentObjectRenderer->getData() knows "TSFE" and allows accessing various properties, partially using a recursive array key mechanism. This area is part of "good old" TypoScript functionality, breaking this could easily become a nightmare for integrators when upgrading to TYPO3 v14: This stdWrap feature is rather hard to understand, is often buried deep in TS setup, is not trivial to test and hard to debug. A compat layer has been established in v13 for other details like ".data = TSFE : fe_user" already, the patch extends this to especially keep support for ".data = TSFE : id" (and some others) for the time being. Resolves: #107527 Related: #105230 Related: #102621 Releases: main Change-Id: I497474a1a8447b4416af11c48c34042adcd19464 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/90777 Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Reviewed-by: Benni Mack <benni@typo3.org> Reviewed-by: Stefan Bürk <stefan@buerk.tech> Tested-by: core-ci <typo3@b13.com> Tested-by: Benni Mack <benni@typo3.org> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Stefan Bürk <stefan@buerk.tech>
1 parent e1871a1 commit 32c3376

File tree

3 files changed

+15
-38
lines changed

3 files changed

+15
-38
lines changed

typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3868,7 +3868,6 @@ public function getData($string, $fieldArray = null)
38683868
$retVal = $this->getValueFromRecursiveData(GeneralUtility::trimExplode('|', $key), $this->getRequest());
38693869
break;
38703870
case 'tsfe':
3871-
// @todo: This needs a bigger cleanup / deprecation when TypoScriptFrontendController continues to remove properties.
38723871
$valueParts = GeneralUtility::trimExplode('|', $key);
38733872
if (($valueParts[0] ?? '') === 'fe_user') {
38743873
$frontendUser = $this->getRequest()->getAttribute('frontend.user');
@@ -3883,8 +3882,20 @@ public function getData($string, $fieldArray = null)
38833882
$this->getRequest()->getQueryParams(),
38843883
GeneralUtility::makeInstance(Context::class)
38853884
);
3886-
} else {
3887-
$retVal = $this->getValueFromRecursiveData($valueParts, $this->getTypoScriptFrontendController());
3885+
} elseif (($valueParts[0] ?? '') === 'id') {
3886+
$retVal = $this->getRequest()->getAttribute('frontend.page.information')->getId();
3887+
} elseif (($valueParts[0] ?? '') === 'contentPid') {
3888+
$retVal = $this->getRequest()->getAttribute('frontend.page.information')->getContentFromPid();
3889+
} elseif (($valueParts[0] ?? '') === 'rootLine') {
3890+
array_shift($valueParts);
3891+
$retVal = $this->getValueFromRecursiveData($valueParts, $this->getRequest()->getAttribute('frontend.page.information')->getRootLine());
3892+
} elseif (($valueParts[0] ?? '') === 'page') {
3893+
array_shift($valueParts);
3894+
$retVal = $this->getValueFromRecursiveData($valueParts, $this->getRequest()->getAttribute('frontend.page.information')->getPageRecord());
3895+
} elseif (($valueParts[0] ?? '') === 'config' && ($valueParts[1] ?? '') === 'rootLine') {
3896+
array_shift($valueParts);
3897+
array_shift($valueParts);
3898+
$retVal = $this->getValueFromRecursiveData($valueParts, $this->getRequest()->getAttribute('frontend.page.information')->getLocalRootLine());
38883899
}
38893900
break;
38903901
case 'getenv':

typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
use TYPO3\CMS\Core\Context\Context;
2727
use TYPO3\CMS\Core\Core\Environment;
2828
use TYPO3\CMS\Core\Database\ConnectionPool;
29-
use TYPO3\CMS\Core\Domain\Repository\PageRepository;
3029
use TYPO3\CMS\Core\Localization\Locale;
3130
use TYPO3\CMS\Core\Localization\Locales;
3231
use TYPO3\CMS\Core\Page\AssetCollector;
@@ -59,33 +58,6 @@
5958
*/
6059
class TypoScriptFrontendController
6160
{
62-
/**
63-
* Use $request->getAttribute('frontend.page.information')->getId() instead.
64-
*/
65-
public int $id;
66-
67-
/**
68-
* Use $request->getAttribute('frontend.page.information')->getRootLine() instead.
69-
*
70-
* @var array<int, array<string, mixed>>
71-
*/
72-
public array $rootLine = [];
73-
74-
/**
75-
* Use $request->getAttribute('frontend.page.information')->getPageRecord() instead.
76-
*/
77-
public ?array $page = [];
78-
79-
/**
80-
* Available as @internal $request->getAttribute('frontend.page.information')->getContentFromPid().
81-
*/
82-
public int $contentPid = 0;
83-
84-
/**
85-
* Create own instance using GeneralUtility::makeInstance(PageRepository::class).
86-
*/
87-
public PageRepository $sys_page;
88-
8961
/**
9062
* A central data array consisting of various keys, initialized and
9163
* processed at various places in the class.
@@ -241,7 +213,6 @@ class TypoScriptFrontendController
241213
*/
242214
public function __construct()
243215
{
244-
$this->sys_page = GeneralUtility::makeInstance(PageRepository::class);
245216
$this->context = GeneralUtility::makeInstance(Context::class);
246217
$this->uniqueString = md5(microtime());
247218
$cacheManager = GeneralUtility::makeInstance(CacheManager::class);
@@ -316,7 +287,7 @@ protected function setPageCacheContent(
316287

317288
// Respect the page cache when content of pid is shown
318289
if ($pageId !== $pageInformation->getContentFromPid()) {
319-
$cacheDataCollector->addCacheTags(new CacheTag('pageId_' . $this->contentPid, $lifetime));
290+
$cacheDataCollector->addCacheTags(new CacheTag('pageId_' . $pageInformation->getContentFromPid(), $lifetime));
320291
}
321292
if (!empty($pageRecord['cache_tags'])) {
322293
$tags = GeneralUtility::trimExplode(',', $pageRecord['cache_tags'], true);

typo3/sysext/frontend/Classes/Middleware/TypoScriptFrontendInitialization.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,6 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
106106

107107
$controller = GeneralUtility::makeInstance(TypoScriptFrontendController::class);
108108
$controller->initializePageRenderer($request);
109-
$controller->id = $pageInformation->getId();
110-
$controller->page = $pageInformation->getPageRecord();
111-
$controller->contentPid = $pageInformation->getContentFromPid();
112-
$controller->rootLine = $pageInformation->getRootLine();
113-
$controller->config['rootLine'] = $pageInformation->getLocalRootLine();
114109
// Update SYS_LASTCHANGED at the very last, when page record was finally resolved.
115110
// Is also called when a translated page is in use, so the register reflects
116111
// the state of the translated page, not the page in the default language.

0 commit comments

Comments
 (0)