Bug #88939

Custom CacheAction cannot send success state and custom flash messages

Added by Guido Schmechel 4 months ago. Updated 11 days ago.

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

100%

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

ext_tables.php View (796 Bytes) Guido Schmechel, 2019-09-25 17:15

FlushFoobarCache.php View (2.53 KB) Guido Schmechel, 2019-09-25 17:18

AjaxRoutes.php View (192 Bytes) 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 translatable Resolved 2019-10-18

Associated revisions

Revision f5f44175 (diff)
Added by Guido Schmechel about 2 months ago

[BUGFIX] Render FlashMessages at ClearCache

Custom Clear Cache implementations can provide their own summary of results.
The content of a JSON response can send a title and message to be displayed
as a Flash message. If an error occurs, a global error message is displayed.

Resolves: #88939
Releases: master, 9.5
Change-Id: I968a06f583bc6c58f9e406fdcb3b32871370b2d2
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/61481
Tested-by: TYPO3com <>
Tested-by: Andreas Fernandez <>
Tested-by: Sascha Rademacher <>
Tested-by: Jörg Bösche <>
Tested-by: Henning Liebe <>
Tested-by: Tobi Kretschmann <>
Reviewed-by: Andreas Fernandez <>
Reviewed-by: Sascha Rademacher <>
Reviewed-by: Jörg Bösche <>
Reviewed-by: Henning Liebe <>
Reviewed-by: Felix P. <>
Reviewed-by: Tobi Kretschmann <>

Revision 5bdd9baa (diff)
Added by Guido Schmechel 11 days ago

[BUGFIX] Render FlashMessages at ClearCache

Custom Clear Cache implementations can provide their own summary of results.
The content of a JSON response can send a title and message to be displayed
as a Flash message. If an error occurs, a global error message is displayed.

Resolves: #88939
Releases: master, 9.5
Change-Id: I968a06f583bc6c58f9e406fdcb3b32871370b2d2
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62001
Tested-by: TYPO3com <>
Tested-by: Henning Liebe <>
Tested-by: Guido Schmechel <>
Tested-by: Georg Ringer <>
Reviewed-by: Henning Liebe <>
Reviewed-by: Guido Schmechel <>
Reviewed-by: Georg Ringer <>

History

#1 Updated by Gerrit Code Review 4 months ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/61481

#2 Updated by Gerrit Code Review 4 months ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/61481

#3 Updated by Gerrit Code Review 3 months ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/61481

#4 Updated by Gerrit Code Review 2 months ago

Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/61481

#5 Updated by Guido Schmechel 2 months ago

Steps to reproduce (in a living extension):

- Change ext_tables.php
- Add Class (Classes/Hooks/Backend/FlushFoobarCache.php)
- Add Routes (Configuration/Backend/AjaxRoutes.php)
- Flush TYPO3 System Cache
- Reload Backend

#6 Updated by Gerrit Code Review 2 months ago

Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/61481

#7 Updated by Gerrit Code Review 2 months ago

Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/61481

#8 Updated by Guido Schmechel about 2 months ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

#9 Updated by Gerrit Code Review about 2 months ago

  • Status changed from Resolved to Under Review

Patch set 1 for branch 9.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62001

#10 Updated by Oliver Bartsch 28 days ago

  • Related to Bug #89447: The notification for an error while clearing the cache is not translatable added

#11 Updated by Guido Schmechel 11 days ago

  • Status changed from Under Review to Resolved

Also available in: Atom PDF