Skip to content

Commit

Permalink
[BUGFIX] Always fetch ContentObject from request in TYPO3v12+
Browse files Browse the repository at this point in the history
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
  • Loading branch information
cweiske authored and NamelessCoder committed Feb 5, 2025
1 parent 41b11dc commit 9912916
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions Classes/Utility/ContentObjectFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,15 @@ public static function resolve(?ConfigurationManagerInterface $configurationMana
? $configurationManager->getRequest()
: ($GLOBALS['TYPO3_REQUEST'] ?? null)) ?? $GLOBALS['TYPO3_REQUEST'] ?? null;

if ($request && $configurationManager === null) {
if ($request) {
$contentObject = static::resolveFromRequest($request);
}

if ($contentObject === null) {
if ($configurationManager !== null && method_exists($configurationManager, 'getContentObject')) {
$contentObject = $configurationManager->getContentObject();
} elseif ($request) {
$contentObject = static::resolveFromRequest($request);
}
if ($contentObject === null
&& $configurationManager !== null
&& method_exists($configurationManager, 'getContentObject')
) {
$contentObject = $configurationManager->getContentObject();
}

return $contentObject;
Expand Down

0 comments on commit 9912916

Please sign in to comment.