/** * Clear the TYPO3 page cache for the given record. * If the record lies on a page, then we clear the cache of this page. * If the record has no PID column, we clear the cache of the current page as best-effort. * * Much of this functionality is taken from t3lib_tcemain::clear_cache() which unfortunately only works with logged-in BE user. * * @param $tableName Table name of the record * @param $uid UID of the record * @return void */ protected function clearPageCache($tableName, $uid) { $extbaseSettings = Tx_Extbase_Dispatcher::getExtbaseFrameworkConfiguration(); if (isset($extbaseSettings['persistence']['enableAutomaticCacheClearing']) && $extbaseSettings['persistence']['enableAutomaticCacheClearing'] === '1') { } else { // if disabled, return return; } $pageIdsToClear = array(); $storagePage = NULL; $columns = $this->databaseHandle->admin_get_fields($tableName); if (array_key_exists('pid', $columns)) { $result = $this->databaseHandle->exec_SELECTquery('pid', $tableName, 'uid=' . intval($uid)); if ($row = $this->databaseHandle->sql_fetch_assoc($result)) { $storagePage = $row['pid']; $pageIdsToClear[] = $storagePage; } } elseif (isset($GLOBALS['TSFE'])) { // No PID column - we can do a best-effort to clear the cache of the current page if in FE $storagePage = $GLOBALS['TSFE']->id; $pageIdsToClear[] = $storagePage; } if ($storagePage === NULL) { return; } if (!isset($this->pageTSConfigCache[$storagePage])) { $this->pageTSConfigCache[$storagePage] = t3lib_BEfunc::getPagesTSconfig($storagePage); } if (isset($this->pageTSConfigCache[$storagePage]['TCEMAIN.']['clearCacheCmd'])) { $clearCacheCommands = t3lib_div::trimExplode(',', strtolower($this->pageTSConfigCache[$storagePage]['TCEMAIN.']['clearCacheCmd']), 1); $clearCacheCommands = array_unique($clearCacheCommands); foreach ($clearCacheCommands as $clearCacheCommand) { if (t3lib_div::testInt($clearCacheCommand)) { $pageIdsToClear[] = $clearCacheCommand; } } } // TODO check if we can hand this over to the Dispatcher to clear the page only once, this will save around 10% time while inserting and updating Tx_Extbase_Utility_Cache::clearPageCache($pageIdsToClear); }
/** * Clear cache of current page on error. Needed because we want a re-evaluation of the data. * Better would be just do delete the cache for the error action, but that is not possible right now. * * @return void */ protected function clearCacheOnError() { $extbaseSettings = Tx_Extbase_Dispatcher::getExtbaseFrameworkConfiguration(); if (isset($extbaseSettings['persistence']['enableAutomaticCacheClearing']) && $extbaseSettings['persistence']['enableAutomaticCacheClearing'] === '1') { if (isset($GLOBALS['TSFE'])) { $pageUid = $GLOBALS['TSFE']->id; Tx_Extbase_Utility_Cache::clearPageCache(array($pageUid)); } } }
/** * Clear cache of current page on error. Needed because we want a re-evaluation of the data. * Better would be just do delete the cache for the error action, but that is not possible right now. * * @return void */ protected function clearCacheOnError() { $extbaseSettings = $this->configurationManager->getConfiguration(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK); if (isset($extbaseSettings['persistence']['enableAutomaticCacheClearing']) && $extbaseSettings['persistence']['enableAutomaticCacheClearing'] === '1') { if (isset($GLOBALS['TSFE'])) { $pageUid = $GLOBALS['TSFE']->id; Tx_Extbase_Utility_Cache::clearPageCache(array($pageUid)); } } }