From b90afef687269b8bae3880403dccbcb9bbf126e2 Mon Sep 17 00:00:00 2001 From: tm-hdaoud Date: Tue, 2 Sep 2025 09:16:31 +0000 Subject: [PATCH 1/5] =?UTF-8?q?hub#18485=20Correction=20d'une=20erreur=20d?= =?UTF-8?q?'invalidation=20de=20cache=20lors=20de=20la=20cr=C3=A9ation=20o?= =?UTF-8?q?u=20la=20suppression=20d'une=20page.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Classes/Cache/CloudFrontCacheManager.php | 11 ++----- Classes/Hooks/ClearCachePostProc.php | 37 ++++++++++++++++++++---- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/Classes/Cache/CloudFrontCacheManager.php b/Classes/Cache/CloudFrontCacheManager.php index 782ce3e..8a07a8b 100644 --- a/Classes/Cache/CloudFrontCacheManager.php +++ b/Classes/Cache/CloudFrontCacheManager.php @@ -327,15 +327,10 @@ public function getLanguagesDomains(int $uid_page): array * @return bool True if there are multiple languages with different domains, false otherwise. */ public function isMultiLanguageDomains(int $uid_page): bool - { - $multi = true; + {; $domains = $this->getLanguagesDomains($uid_page); - foreach ($domains as $lang => $domain) { - if (strpos($domain, '.') === false) { - $multi = false; - } - } - return $multi; + + return count(array_unique(array_map('strtolower', $domains))) > 1; } /** diff --git a/Classes/Hooks/ClearCachePostProc.php b/Classes/Hooks/ClearCachePostProc.php index 1674b0f..4cfe2f1 100644 --- a/Classes/Hooks/ClearCachePostProc.php +++ b/Classes/Hooks/ClearCachePostProc.php @@ -17,6 +17,7 @@ namespace Toumoro\TmCloudfront\Hooks; +use Doctrine\DBAL\ParameterType; use Toumoro\TmCloudfront\Cache\CloudFrontCacheManager; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -33,7 +34,9 @@ class ClearCachePostProc protected CloudFrontCacheManager $cacheManager; - public function __construct() + public function __construct( + protected SiteFinder $siteFinder + ) { $this->cloudFrontConfiguration = GeneralUtility::makeInstance(ExtensionConfiguration::class) ->get('tm_cloudfront')['cloudfront']; @@ -105,8 +108,10 @@ public function clearCachePostProc(&$params, &$pObj): void $distributionIds = $this->getDistributionIds($uid_page, $params); // Priority to TsConfig settings - if (!empty($tsConfig['distributionIds'])) { - $distributionIds = $tsConfig['distributionIds']; + if (!empty($tsConfig['TCEMAIN.'])) { + if(!empty($tsConfig['TCEMAIN.']['distributionIds'])) { + $distributionIds = $tsConfig['TCEMAIN.']['distributionIds']; + } } // If the record is not a page, enqueue only the current page @@ -178,8 +183,10 @@ protected function getDistributionsFromDomains(array $domains): string protected function getDistributionIds(int $uid_page, array $params): string { $domain = ''; - if ($uid_page > 0 && isset($params['table'], $params['uid'])) { - $site = GeneralUtility::makeInstance(SiteFinder::class)->getSiteByPageId($uid_page); + + if ($uid_page > 0 && isset($params['table'], $params['uid']) && !$this->isPageDeleted($uid_page)) { + $site = $this->siteFinder->getSiteByPageId($uid_page); + $row = GeneralUtility::makeInstance(ConnectionPool::class) ->getQueryBuilderForTable($params['table']) ->select('*') @@ -206,4 +213,24 @@ protected function getDistributionIds(int $uid_page, array $params): string return $distributionIds; } + + private function isPageDeleted($uid): int + { + $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) + ->getQueryBuilderForTable('pages'); + + $queryBuilder->getRestrictions()->removeAll(); + + return (int)$queryBuilder + ->select('deleted') + ->from('pages') + ->where( + $queryBuilder->expr()->eq( + 'uid', + $queryBuilder->createNamedParameter($uid, ParameterType::INTEGER) + ) + ) + ->executeQuery() + ->fetchOne(); + } } From 2b934dc7adfecc75d943bb88e7b90a93767ce54a Mon Sep 17 00:00:00 2001 From: tm-hdaoud Date: Tue, 2 Sep 2025 09:21:21 +0000 Subject: [PATCH 2/5] =?UTF-8?q?hub#18485=20Correction=20d'une=20erreur=20d?= =?UTF-8?q?'invalidation=20de=20cache=20lors=20de=20la=20cr=C3=A9ation=20o?= =?UTF-8?q?u=20la=20suppression=20d'une=20page.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 7 +++++++ ext_emconf.php | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..611c195 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,7 @@ +# Changelog +All notable changes to this extension will be documented in this file. + +## [13.0.4] - 2025-09-02 + +### Fixed +- Fixed cache invalidation bug when creating or deleting a page. \ No newline at end of file diff --git a/ext_emconf.php b/ext_emconf.php index 174dcea..8ebe8e0 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -17,7 +17,7 @@ 'author' => 'Simon Ouellet', 'author_email' => '', 'state' => 'beta', - 'version' => '13.0.2', + 'version' => '13.0.4', 'constraints' => [ 'depends' => [ 'typo3' => '12.4.0-13.5.99', From e49080734b06c1a293f1d020d7885f59ae863117 Mon Sep 17 00:00:00 2001 From: tm-hdaoud Date: Tue, 2 Sep 2025 09:21:52 +0000 Subject: [PATCH 3/5] =?UTF-8?q?hub#18485=20Correction=20d'une=20erreur=20d?= =?UTF-8?q?'invalidation=20de=20cache=20lors=20de=20la=20cr=C3=A9ation=20o?= =?UTF-8?q?u=20la=20suppression=20d'une=20page.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 +- ext_emconf.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 611c195..ebfcc0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # Changelog All notable changes to this extension will be documented in this file. -## [13.0.4] - 2025-09-02 +## [13.0.3] - 2025-09-02 ### Fixed - Fixed cache invalidation bug when creating or deleting a page. \ No newline at end of file diff --git a/ext_emconf.php b/ext_emconf.php index 8ebe8e0..23a77c2 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -17,7 +17,7 @@ 'author' => 'Simon Ouellet', 'author_email' => '', 'state' => 'beta', - 'version' => '13.0.4', + 'version' => '13.0.3', 'constraints' => [ 'depends' => [ 'typo3' => '12.4.0-13.5.99', From ae342790c562a9aa6a715a0960abdce235e46ec1 Mon Sep 17 00:00:00 2001 From: tm-hdaoud Date: Tue, 2 Sep 2025 09:49:32 +0000 Subject: [PATCH 4/5] =?UTF-8?q?hub#18485=20Correction=20d'une=20erreur=20d?= =?UTF-8?q?'invalidation=20de=20cache=20lors=20de=20la=20cr=C3=A9ation=20o?= =?UTF-8?q?u=20la=20suppression=20d'une=20page.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Classes/Cache/CloudFrontCacheManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/Cache/CloudFrontCacheManager.php b/Classes/Cache/CloudFrontCacheManager.php index 8a07a8b..f9f2fcb 100644 --- a/Classes/Cache/CloudFrontCacheManager.php +++ b/Classes/Cache/CloudFrontCacheManager.php @@ -253,7 +253,7 @@ public function queueClearCache(int $pageId, bool $recursive = false, string|nul if (count($languages) > 0) { if ($this->isMultiLanguageDomains($entry)) { - $this->enqueue($this->buildLink($entry, array('_language' => 0)) . $wildcard, $this->distributionsMapping[$languages[0]->getBase()->getHost()]); + $this->enqueue($this->buildLink($entry, array('_language' => 0)) . $wildcard, $this->distributionsMapping[(string)$languages[0]->getBase()->getHost()]); foreach ($languages as $k => $lang) { if ($lang->getLanguageId() != 0) { $this->enqueue($this->buildLink($entry, array('_language' => $lang->getLanguageId())) . $wildcard, $this->distributionsMapping[$lang->getBase()->getHost()]); From ca6f0b4d813706215e9189656c413199d6d9206f Mon Sep 17 00:00:00 2001 From: tm-hdaoud Date: Tue, 2 Sep 2025 12:29:15 +0000 Subject: [PATCH 5/5] =?UTF-8?q?hub#18485=20Correction=20d'une=20erreur=20d?= =?UTF-8?q?'invalidation=20de=20cache=20lors=20de=20la=20cr=C3=A9ation=20o?= =?UTF-8?q?u=20la=20suppression=20d'une=20page.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 +- ext_emconf.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ebfcc0f..611c195 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # Changelog All notable changes to this extension will be documented in this file. -## [13.0.3] - 2025-09-02 +## [13.0.4] - 2025-09-02 ### Fixed - Fixed cache invalidation bug when creating or deleting a page. \ No newline at end of file diff --git a/ext_emconf.php b/ext_emconf.php index 23a77c2..8ebe8e0 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -17,7 +17,7 @@ 'author' => 'Simon Ouellet', 'author_email' => '', 'state' => 'beta', - 'version' => '13.0.3', + 'version' => '13.0.4', 'constraints' => [ 'depends' => [ 'typo3' => '12.4.0-13.5.99',