Bug #88939

Custom CacheAction cannot send success state and custom flash messages

Added by Guido Schmechel almost 2 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Backend JavaScript
Target version:
-
Start date:
2019-08-08
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
9
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Content:
Add a cacheAction via $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['additionalBackendItems']['cacheActions']. Everything is fine and the cache icon is displayed in the topbar. Sending a JsonResponse via interface:

    /**
     * @param ServerRequestInterface $request
     * @return ResponseInterface
     */
    public function flush(ServerRequestInterface $request): ResponseInterface
    {
        return new JsonResponse(['success' => true]);
    }

We get a red FlashMessage with the hardcoded "An error occurred while clearing the cache. It is likely not all caches were cleared as expected." text.

The message is thrown from https://github.com/TYPO3/TYPO3.CMS/blob/master/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/Toolbar/ClearCacheMenu.ts#L72 because we have a response. It does not matter what is inside, as you can see.

Solution:
We need a proper solution for this typescript case. Luckily we have a similar solution here: https://github.com/TYPO3/TYPO3.CMS/blob/master/Build/Sources/TypeScript/recordlist/Resources/Public/TypeScript/ClearCache.ts#L67


Files

ext_tables.php (796 Bytes) ext_tables.php Guido Schmechel, 2019-09-25 17:15
FlushFoobarCache.php (2.53 KB) FlushFoobarCache.php Guido Schmechel, 2019-09-25 17:18
AjaxRoutes.php (192 Bytes) AjaxRoutes.php Guido Schmechel, 2019-09-25 17:18

Related issues

Related to TYPO3 Core - Bug #89447: The notification for an error while clearing the cache is not translatableClosed2019-10-18

Actions

Also available in: Atom PDF