georgringer / news

TYPO3 Extension news
GNU General Public License v2.0
263 stars 357 forks source link

clearCachePostProc hook repeats calls #2505

Open heifiDR opened 1 month ago

heifiDR commented 1 month ago

Bug Report

Current Behavior When the clearCachePostProc() in the DataHandlerHook is called, it always writes 2 entries to the $cacheTagsToFlush array. It then loops through the array and executes $cacheManager->flushCachesInGroupByTag(). Because the class is a singleton, the $cacheTagsToFlush array is never deleted. This means that when another news item is deleted, the cache for all previous items is emptied again.

With 115 deleted news elements, that are on the same page, the $cacheManager->flushCachesInGroupByTag() call occurs over 6600 times.

Expected behavior/output The $cacheManager->flushCachesInGroupByTag() should just be called once per item and page.

Environment

Possible Solution There are different ways to solve this. The fastest solution could be to reset the $cacheTagsToFlush array on each hook call, but this would still trigger multiple calls for the same page. The cleanest approach would probably be to collect alle $cacheTagsToFlush in an earlier hook and to clear it in the clearCachePostProc() Hook.

georgringer commented 1 month ago

wanna provide a PR to improve the situation? last suggestion looks best