Commit e9dae46a authored by Benjamin Franzke's avatar Benjamin Franzke
Browse files

[BUGFIX] Fix cache clearing when publishing from workspace

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's avatarcore-ci <typo3@b13.com>
Tested-by: Nikita Hovratov's avatarNikita Hovratov <nikita.h@live.de>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Tested-by: Benjamin Franzke's avatarBenjamin Franzke <bfr@qbus.de>
Reviewed-by: Nikita Hovratov's avatarNikita Hovratov <nikita.h@live.de>
Reviewed-by: default avatarGuido Schmechel <guido.schmechel@brandung.de>
Reviewed-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Benjamin Franzke's avatarBenjamin Franzke <bfr@qbus.de>
parent c3c3da21
......@@ -8541,9 +8541,35 @@ class DataHandler implements LoggerAwareInterface
$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 = [];
......@@ -8656,7 +8682,7 @@ class DataHandler implements LoggerAwareInterface
$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);
}
......
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