Skip to content

Commit

Permalink
[BUGFIX] Fix cache clearing when publishing from workspace
Browse files Browse the repository at this point in the history
With #89555 cache clearing has been disabled
if the user is currently in a workspace.

This is fine in most cases, but if a record is published
to live, cache clearing needs to be enabled.

Resolves: #95600
Related: #89555
Releases: master, 10.4
Change-Id: Ic69baa3439912740abbfbb03d5ac6a076e46410a
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/71799
Tested-by: core-ci <typo3@b13.com>
Tested-by: Nikita Hovratov <nikita.h@live.de>
Tested-by: Benni Mack <benni@typo3.org>
Tested-by: Benjamin Franzke <bfr@qbus.de>
Reviewed-by: Nikita Hovratov <nikita.h@live.de>
Reviewed-by: Guido Schmechel <guido.schmechel@brandung.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Benni Mack <benni@typo3.org>
Reviewed-by: Benjamin Franzke <bfr@qbus.de>
  • Loading branch information
bnf committed Nov 4, 2021
1 parent c3c3da2 commit e9dae46
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions typo3/sysext/core/Classes/DataHandling/DataHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -8541,9 +8541,35 @@ protected function prepareCacheFlush($table, $uid, $pid)
$tagsToClear = [];
$clearCacheCommands = [];
$pageUid = 0;
$clearCacheEnabled = true;
// Get Page TSconfig relevant:
$TSConfig = BackendUtility::getPagesTSconfig($pid)['TCEMAIN.'] ?? [];
if (empty($TSConfig['clearCache_disable']) && $this->BE_USER->workspace === 0) {

if (!empty($TSConfig['clearCache_disable'])) {
$clearCacheEnabled = false;
}

if ($clearCacheEnabled && $this->BE_USER->workspace !== 0 && BackendUtility::isTableWorkspaceEnabled($table)) {
$connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
$queryBuilder = $connectionPool->getQueryBuilderForTable($table);
$queryBuilder->getRestrictions()
->removeAll()
->add(GeneralUtility::makeInstance(DeletedRestriction::class));
$count = $queryBuilder
->count('uid')
->from($table)
->where(
$queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)),
$queryBuilder->expr()->eq('t3ver_oid', 0)
)
->execute()
->fetchColumn();
if ($count === 0) {
$clearCacheEnabled = false;
}
}

if ($clearCacheEnabled) {
$connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
// If table is "pages":
$pageIdsThatNeedCacheFlush = [];
Expand Down Expand Up @@ -8656,7 +8682,7 @@ protected function prepareCacheFlush($table, $uid, $pid)
$clearCacheCommands = array_unique($commands);
}
// Call post processing function for clear-cache:
$_params = ['table' => $table, 'uid' => $uid, 'uid_page' => $pageUid, 'TSConfig' => $TSConfig, 'tags' => $tagsToClear];
$_params = ['table' => $table, 'uid' => $uid, 'uid_page' => $pageUid, 'TSConfig' => $TSConfig, 'tags' => $tagsToClear, 'clearCacheEnabled' => $clearCacheEnabled];
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearCachePostProc'] ?? [] as $_funcRef) {
GeneralUtility::callUserFunction($_funcRef, $_params, $this);
}
Expand Down

0 comments on commit e9dae46

Please sign in to comment.