Commit c6a0de45 authored by Frank Nägler's avatar Frank Nägler Committed by Susanne Moog
Browse files

[FEATURE] Simplify cache clearing

The cache clearing system has been simplified by removing options in
cache clear menu and install tool.

Resolves: #75581
Releases: master
Change-Id: Ia784efb13e443705b1be3326ba12107b885e8268
Reviewed-on: https://review.typo3.org/47580


Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: default avatarSusanne Moog <typo3@susannemoog.de>
Tested-by: default avatarSusanne Moog <typo3@susannemoog.de>
parent a34fc5dd
......@@ -297,6 +297,12 @@
background-color: @brand-danger;
color: @btn-danger-color;
}
small {
white-space: normal;
width: 270px;
display: block;
padding-left: 21px;
}
}
.dropdown-list-link-edit,
.dropdown-list-link-delete,
......
......@@ -67,24 +67,11 @@ class ClearCacheToolbarItem implements ToolbarItemInterface
$this->optionValues[] = 'pages';
}
// Clear cache for ALL tables!
if ($backendUser->isAdmin() || $backendUser->getTSConfigVal('options.clearCache.all')) {
$this->cacheActions[] = array(
'id' => 'all',
'title' => htmlspecialchars($languageService->sL('LLL:EXT:lang/locallang_core.xlf:flushGeneralCachesTitle')),
'description' => htmlspecialchars($languageService->sL('LLL:EXT:lang/locallang_core.xlf:flushGeneralCachesDescription')),
'href' => BackendUtility::getModuleUrl('tce_db', ['vC' => $backendUser->veriCode(), 'cacheCmd' => 'all']),
'icon' => $this->iconFactory->getIcon('actions-system-cache-clear-impact-medium', Icon::SIZE_SMALL)->render()
);
$this->optionValues[] = 'all';
}
// Clearing of system cache (core cache, class cache etc)
// is only shown explicitly if activated for a BE-user (not activated for admins by default)
// or if the system runs in development mode (only for admins)
// or if $GLOBALS['TYPO3_CONF_VARS']['SYS']['clearCacheSystem'] is set (only for admins)
if (
$backendUser->getTSConfigVal('options.clearCache.system')
if ($backendUser->getTSConfigVal('options.clearCache.all')
|| (GeneralUtility::getApplicationContext()->isDevelopment() && $backendUser->isAdmin())
|| ((bool)$GLOBALS['TYPO3_CONF_VARS']['SYS']['clearCacheSystem'] === true && $backendUser->isAdmin())
) {
......@@ -92,10 +79,10 @@ class ClearCacheToolbarItem implements ToolbarItemInterface
'id' => 'system',
'title' => htmlspecialchars($languageService->sL('LLL:EXT:lang/locallang_core.xlf:flushSystemCachesTitle')),
'description' => htmlspecialchars($languageService->sL('LLL:EXT:lang/locallang_core.xlf:flushSystemCachesDescription')),
'href' => BackendUtility::getModuleUrl('tce_db', ['vC' => $backendUser->veriCode(), 'cacheCmd' => 'system']),
'href' => BackendUtility::getModuleUrl('tce_db', ['vC' => $backendUser->veriCode(), 'cacheCmd' => 'all']),
'icon' => $this->iconFactory->getIcon('actions-system-cache-clear-impact-high', Icon::SIZE_SMALL)->render()
);
$this->optionValues[] = 'system';
$this->optionValues[] = 'all';
}
// Hook for manipulating cacheActions
......@@ -156,8 +143,9 @@ class ClearCacheToolbarItem implements ToolbarItemInterface
foreach ($this->cacheActions as $cacheAction) {
$title = $cacheAction['description'] ?: $cacheAction['title'];
$result[] = '<li>';
$result[] = '<a class="dropdown-list-link" href="' . htmlspecialchars($cacheAction['href']) . '" title="' . htmlspecialchars($title) . '">';
$result[] = '<a class="dropdown-list-link" href="' . htmlspecialchars($cacheAction['href']) . '">';
$result[] = $cacheAction['icon'] . ' ' . htmlspecialchars($cacheAction['title']);
$result[] = '<br/><small>' . htmlspecialchars($title) . '</small>';
$result[] = '</a>';
$result[] = '</li>';
}
......
......@@ -16,7 +16,7 @@
* main functionality for clearing caches via the top bar
* reloading the clear cache icon
*/
define(['jquery', 'TYPO3/CMS/Backend/Icons'], function($, Icons) {
define(['jquery', 'TYPO3/CMS/Backend/Icons', 'TYPO3/CMS/Backend/Notification'], function($, Icons, Notification) {
'use strict';
/**
......@@ -67,8 +67,11 @@ define(['jquery', 'TYPO3/CMS/Backend/Icons'], function($, Icons) {
url: ajaxUrl,
type: 'post',
cache: false,
complete: function() {
complete: function(jqXHRObject, status) {
$(ClearCacheMenu.options.toolbarIconSelector, ClearCacheMenu.options.containerSelector).replaceWith($existingIcon);
if (status !== 'success' || jqXHRObject.responseText !== '') {
Notification.error('An error occurs', 'An error occured while clearing the cache. It is likely not all caches were cleared as expected.', 0);
}
}
});
};
......
......@@ -27,14 +27,17 @@ use TYPO3\CMS\Core\Html\RteHtmlParser;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Messaging\FlashMessageService;
use TYPO3\CMS\Core\Resource\ResourceFactory;
use TYPO3\CMS\Core\Service\OpcodeCacheService;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\File\BasicFileUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
use TYPO3\CMS\Core\Utility\StringUtility;
use TYPO3\CMS\Core\Versioning\VersionState;
use TYPO3\CMS\Install\Service\ClearCacheService;
/**
* The main data handler class which takes care of correctly updating and inserting records.
......@@ -7803,7 +7806,6 @@ class DataHandler
if (is_object($this->BE_USER)) {
$this->BE_USER->writelog(3, 1, 0, 0, 'User %s has cleared the cache (cacheCmd=%s)', array($this->BE_USER->user['username'], $cacheCmd));
}
// Clear cache for either ALL pages or ALL tables!
switch (strtolower($cacheCmd)) {
case 'pages':
if ($this->admin || $this->BE_USER->getTSConfigVal('options.clearCache.pages')) {
......@@ -7812,11 +7814,13 @@ class DataHandler
break;
case 'all':
if ($this->admin || $this->BE_USER->getTSConfigVal('options.clearCache.all')) {
// Clear cache group "all" of caching framework caches
$this->getCacheManager()->flushCachesInGroup('all');
// Delete typo3temp/var/Cache manually as quick, straight and brutal approach here
GeneralUtility::flushDirectory(PATH_site . 'typo3temp/var/Cache', true, true);
$this->getCacheManager()->flushCaches();
$this->databaseConnection->exec_TRUNCATEquery('cache_treelist');
// Delete Opcode Cache
GeneralUtility::makeInstance(OpcodeCacheService::class)->clearAllActive();
}
break;
case 'temp_cached':
case 'system':
......
=========================================
Feature: #75581 - Simplify cache clearing
=========================================
Description
===========
The cache clearing system has been simplified by removing options in cache clear menu and install tool.
The cache clear menu in the backend contains now only two options:
* Flush frontend caches
Clear frontend and page-related caches, like before.
* Flush all caches
Clear all system-related caches, including the class loader, localization, extension configuration file caches and opcode caches. Rebuilding this cache may take some time.
Within the install tool the "Clear all cache" button will clear now also the opcode caches if possible.
......@@ -48,8 +48,6 @@ class ImportantActions extends Action\AbstractAction
}
if (isset($this->postValues['set']['clearAllCache'])) {
$actionMessages[] = $this->clearAllCache();
}
if (isset($this->postValues['set']['clearOpcodeCache'])) {
$actionMessages[] = $this->clearOpcodeCache();
}
......
......@@ -7,7 +7,22 @@
This method can throw a fatal error if a broken extension is loaded. If you get a white page
or a PHP error message, check your system with the broken extension test below.
</p>
<p>
This clears the complete opcode caches of the active opcode cache systems, if the system supports reset.
</p>
<p>Available PHP opcode cache systems</p>
<ul>
<f:for each="{listOfOpcodeCaches}" as="opcodeCache" key="opcodeCacheName">
<li>{opcodeCacheName} ({opcodeCache.version}) -
<f:if condition="{opcodeCache.canReset}">
<f:then>reset is supported</f:then>
<f:else>reset is not supported</f:else>
</f:if>
</li>
</f:for>
</ul>
<form method="post">
<f:render partial="Action/Common/HiddenFormFields" arguments="{_all}" />
<f:render partial="Action/Common/SubmitButton" arguments="{name:'clearAllCache', text:'Clear all cache'}"/>
<f:render partial="Action/Common/SubmitButton" arguments="{name:'clearAllCache', text:'Clear all caches including PHP opcode cache'}"/>
</form>
<f:if condition="{listOfOpcodeCaches}">
<h3>Clear PHP opcode cache</h3>
<p>
This clears the complete opcode caches of the active opcode cache systems, if the system supports reset.
</p>
<p>Available PHP opcode cache systems</p>
<ul>
<f:for each="{listOfOpcodeCaches}" as="opcodeCache" key="opcodeCacheName">
<li>{opcodeCacheName} ({opcodeCache.version}) -
<f:if condition="{opcodeCache.canReset}">
<f:then>reset is supported</f:then>
<f:else>reset is not supported</f:else>
</f:if>
</li>
</f:for>
</ul>
<form method="post">
<f:render partial="Action/Common/HiddenFormFields" arguments="{_all}" />
<f:render partial="Action/Common/SubmitButton" arguments="{name:'clearOpcodeCache', text:'Clear PHP opcode cache'}"/>
</form>
<hr />
</f:if>
......@@ -25,8 +25,6 @@
<f:render partial="Action/Tool/ImportantActions/ClearAllCache" arguments="{_all}"/>
<hr />
<f:render partial="Action/Tool/ImportantActions/ClearOpcodeCache" arguments="{_all}"/>
<f:render partial="Action/Tool/ImportantActions/ExtensionCompatibilityTester" arguments="{_all}"/>
<hr />
......
......@@ -876,10 +876,10 @@ Do you want to refresh it now?</source>
<source>Clear frontend and page-related caches, plus some backend-related caches.</source>
</trans-unit>
<trans-unit id="flushSystemCachesTitle">
<source>Flush system caches</source>
<source>Flush all caches</source>
</trans-unit>
<trans-unit id="flushSystemCachesDescription">
<source>Clear all system-related caches, including the class loader, localization and extension configuration file caches. Rebuilding this cache may take some time. </source>
<source>Clear all system-related caches, including the class loader, localization, extension configuration file caches and opcode caches. Rebuilding this cache may take some time.</source>
</trans-unit>
<trans-unit id="rm.adminFunctions">
<source>Admin functions</source>
......
......@@ -12578,6 +12578,12 @@ iframe {
background-color: #c83c3c;
color: #ffffff;
}
.typo3-topbar-navigation-items .dropdown-list-link small {
white-space: normal;
width: 270px;
display: block;
padding-left: 21px;
}
.typo3-topbar-navigation-items .dropdown-list-link-edit,
.typo3-topbar-navigation-items .dropdown-list-link-delete,
.typo3-topbar-navigation-items .dropdown-list-link-close {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment