Skip to content

Commit 9912916

Browse files
cweiskeNamelessCoder
authored andcommitted
[BUGFIX] Always fetch ContentObject from request in TYPO3v12+
The ContentObjectFetcher was introduced to have a common API for fetching the current content object across different TYPO3 versions. This class logs a deprecation notice in TYPO3v12: > TYPO3 Deprecation Notice: > ConfigurationManager->getContentObject() is deprecated since TYPO3 v12.4 > and will be removed in v13.0. > Fetch the current content object from request attribute > "currentContentObject" instead in > vendor/typo3/cms-extbase/Classes/Configuration/ConfigurationManager.php > line 96 To prevent this from happening, we check for the TYPO3 version and always use the request instead of the configuration manager in TYPO3v12+. Related: #1920 Related: #1921
1 parent 41b11dc commit 9912916

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

Classes/Utility/ContentObjectFetcher.php

+6-7
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,15 @@ public static function resolve(?ConfigurationManagerInterface $configurationMana
2222
? $configurationManager->getRequest()
2323
: ($GLOBALS['TYPO3_REQUEST'] ?? null)) ?? $GLOBALS['TYPO3_REQUEST'] ?? null;
2424

25-
if ($request && $configurationManager === null) {
25+
if ($request) {
2626
$contentObject = static::resolveFromRequest($request);
2727
}
2828

29-
if ($contentObject === null) {
30-
if ($configurationManager !== null && method_exists($configurationManager, 'getContentObject')) {
31-
$contentObject = $configurationManager->getContentObject();
32-
} elseif ($request) {
33-
$contentObject = static::resolveFromRequest($request);
34-
}
29+
if ($contentObject === null
30+
&& $configurationManager !== null
31+
&& method_exists($configurationManager, 'getContentObject')
32+
) {
33+
$contentObject = $configurationManager->getContentObject();
3534
}
3635

3736
return $contentObject;

0 commit comments

Comments
 (0)