Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX] Replace deprecated addCacheTags calls #2531

Open
wants to merge 1 commit into
base: 12-13
Choose a base branch
from

Conversation

heinrob
Copy link

@heinrob heinrob commented Sep 23, 2024

TSFE->addCacheTags() has been deprecated in TYPO3 13.3, see: https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/13.3/Deprecation-102422-TypoScriptFrontendController-addCacheTags.html This results in a TypeError in the frontend where the plugin is used. In this patch, the calls have been updated to use newly instantiated CacheTag objects instead of an array of strings.

Resolves: #2530

TSFE->addCacheTags() has been deprecated in TYPO3 13.3, see: https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/13.3/Deprecation-102422-TypoScriptFrontendController-addCacheTags.html
This results in a TypeError in the frontend where the plugin is used.
In this patch, the calls have been updated to use newly instantiated CacheTag objects instead of an array of strings.

Resolves: georgringer#2530
@@ -59,6 +60,7 @@ public function isContentRecordAlreadyProcessed(ContentObjectRenderer $cObj): bo
public static function addCacheTagsByNewsRecords($newsRecords): void
{
$cacheTags = [];
$cacheDataCollector = $GLOBALS['TYPO3_REQUEST']->getAttribute('frontend.cache.collector');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$cacheDataCollector = $GLOBALS['TYPO3_REQUEST']->getAttribute('frontend.cache.collector');
$cacheDataCollector = self::getRequest()->getAttribute('frontend.cache.collector');

@@ -83,6 +82,7 @@ public static function addCacheTagsByNewsRecords($newsRecords): void
public static function addPageCacheTagsByDemandObject(NewsDemand $demand): void
{
$cacheTags = [];
$cacheDataCollector = $GLOBALS['TYPO3_REQUEST']->getAttribute('frontend.cache.collector');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$cacheDataCollector = $GLOBALS['TYPO3_REQUEST']->getAttribute('frontend.cache.collector');
$cacheDataCollector = self::getRequest()->getAttribute('frontend.cache.collector');

And add static method to get the request:

protected static function getRequest()
{
    return $GLOBALS['TYPO3_REQUEST'];
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants