|
@@ -3,10 +3,9 @@
|
|
|
namespace Opentalent\OtCore\Cache;
|
|
namespace Opentalent\OtCore\Cache;
|
|
|
|
|
|
|
|
use Opentalent\OtCore\Website\OtPageRepository;
|
|
use Opentalent\OtCore\Website\OtPageRepository;
|
|
|
-use TYPO3\CMS\Core\Service\OpcodeCacheService;
|
|
|
|
|
|
|
+use TYPO3\CMS\Core\Database\ConnectionPool;
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
|
|
use TYPO3\CMS\Extbase\Object\ObjectManager;
|
|
use TYPO3\CMS\Extbase\Object\ObjectManager;
|
|
|
-use TYPO3\CMS\Install\Service\ClearCacheService;
|
|
|
|
|
use TYPO3\CMS\Core\Cache\CacheManager;
|
|
use TYPO3\CMS\Core\Cache\CacheManager;
|
|
|
|
|
|
|
|
class OtCacheManager
|
|
class OtCacheManager
|
|
@@ -30,7 +29,7 @@ class OtCacheManager
|
|
|
* @param int $pageUid
|
|
* @param int $pageUid
|
|
|
* @param bool $clearAll if true, all caches will be cleared, and not only the frontend one
|
|
* @param bool $clearAll if true, all caches will be cleared, and not only the frontend one
|
|
|
*/
|
|
*/
|
|
|
- public static function clearSiteCache(int $pageUid, $clearAll=false) {
|
|
|
|
|
|
|
+ public static function clearSiteCache(int $pageUid, bool $clearAll = false) {
|
|
|
|
|
|
|
|
$pageRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtPageRepository::class);
|
|
$pageRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtPageRepository::class);
|
|
|
$rootPage = $pageRepository->getRootPageFor($pageUid);
|
|
$rootPage = $pageRepository->getRootPageFor($pageUid);
|
|
@@ -43,10 +42,37 @@ class OtCacheManager
|
|
|
return 'pageId_' . $page['uid'];
|
|
return 'pageId_' . $page['uid'];
|
|
|
}, $pages);
|
|
}, $pages);
|
|
|
|
|
|
|
|
- if (!$clearAll) {
|
|
|
|
|
|
|
+ if ($clearAll) {
|
|
|
|
|
+ $cacheManager->flushCachesByTags($tags);
|
|
|
|
|
+ } else {
|
|
|
$cacheManager->flushCachesInGroupByTags('pages', $tags);
|
|
$cacheManager->flushCachesInGroupByTags('pages', $tags);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // << BUGFIX: without this, the fluid templates caches are not cleared
|
|
|
|
|
+ $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
|
|
|
|
|
+ $cnn = $connectionPool->getConnectionByName('Default');
|
|
|
|
|
+ $cnn->beginTransaction();
|
|
|
|
|
+ $sql = "update typo3.cache_hash h inner join typo3.cache_hash_tags t on h.id = t.id
|
|
|
|
|
+ set h.expires = 0
|
|
|
|
|
+ where t.tag = 'ident_TS_TEMPLATE';";
|
|
|
|
|
+ $stmt = $cnn->prepare($sql);
|
|
|
|
|
+ $stmt->executeQuery();
|
|
|
|
|
+ $cnn->commit();
|
|
|
|
|
+ // >>
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Clears cache
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param bool $clearAll if true, all caches will be cleared, and not only the frontend one
|
|
|
|
|
+ */
|
|
|
|
|
+ public static function clearCache($clearAll) {
|
|
|
|
|
+ $cacheManager = GeneralUtility::makeInstance(CacheManager::class);
|
|
|
|
|
+
|
|
|
|
|
+ if ($clearAll) {
|
|
|
|
|
+ $cacheManager->flushCachesInGroup('pages');
|
|
|
} else {
|
|
} else {
|
|
|
- $cacheManager->flushCachesByTags($tags);
|
|
|
|
|
|
|
+ $cacheManager->flushCaches();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|