コード例 #1
0
ファイル: DataHandler.php プロジェクト: rickymathew/TYPO3.CMS
 /**
  * Do the actual clear cache
  * @return void
  */
 protected function processClearCacheQueue()
 {
     $tagsToClear = array();
     $clearCacheCommands = array();
     foreach (static::$recordsToClearCacheFor as $table => $uids) {
         foreach (array_unique($uids) as $uid) {
             $pageUid = 0;
             if (!isset($GLOBALS['TCA'][$table]) || $uid <= 0) {
                 return;
             }
             // Get Page TSconfig relevant:
             list($tscPID) = BackendUtility::getTSCpid($table, $uid, '');
             $TSConfig = $this->getTCEMAIN_TSconfig($tscPID);
             if (empty($TSConfig['clearCache_disable'])) {
                 // If table is "pages":
                 $pageIdsThatNeedCacheFlush = array();
                 if ($table === 'pages' || $table === 'pages_language_overlay') {
                     if ($table === 'pages_language_overlay') {
                         $pageUid = $this->getPID($table, $uid);
                     } else {
                         $pageUid = $uid;
                     }
                     // Builds list of pages on the SAME level as this page (siblings)
                     $res_tmp = $this->databaseConnection->exec_SELECTquery('A.pid AS pid, B.uid AS uid', 'pages A, pages B', 'A.uid=' . (int) $pageUid . ' AND B.pid=A.pid AND B.deleted=0');
                     $pid_tmp = 0;
                     while ($row_tmp = $this->databaseConnection->sql_fetch_assoc($res_tmp)) {
                         $pageIdsThatNeedCacheFlush[] = (int) $row_tmp['uid'];
                         $pid_tmp = $row_tmp['pid'];
                         // Add children as well:
                         if ($TSConfig['clearCache_pageSiblingChildren']) {
                             $res_tmp2 = $this->databaseConnection->exec_SELECTquery('uid', 'pages', 'pid=' . (int) $row_tmp['uid'] . ' AND deleted=0');
                             while ($row_tmp2 = $this->databaseConnection->sql_fetch_assoc($res_tmp2)) {
                                 $pageIdsThatNeedCacheFlush[] = (int) $row_tmp2['uid'];
                             }
                             $this->databaseConnection->sql_free_result($res_tmp2);
                         }
                     }
                     $this->databaseConnection->sql_free_result($res_tmp);
                     // Finally, add the parent page as well:
                     $pageIdsThatNeedCacheFlush[] = (int) $pid_tmp;
                     // Add grand-parent as well:
                     if ($TSConfig['clearCache_pageGrandParent']) {
                         $res_tmp = $this->databaseConnection->exec_SELECTquery('pid', 'pages', 'uid=' . (int) $pid_tmp);
                         if ($row_tmp = $this->databaseConnection->sql_fetch_assoc($res_tmp)) {
                             $pageIdsThatNeedCacheFlush[] = (int) $row_tmp['pid'];
                         }
                         $this->databaseConnection->sql_free_result($res_tmp);
                     }
                 } else {
                     // For other tables than "pages", delete cache for the records "parent page".
                     $pageIdsThatNeedCacheFlush[] = $pageUid = (int) $this->getPID($table, $uid);
                 }
                 // Call pre-processing function for clearing of cache for page ids:
                 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearPageCacheEval'])) {
                     foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearPageCacheEval'] as $funcName) {
                         $_params = array('pageIdArray' => &$pageIdsThatNeedCacheFlush, 'table' => $table, 'uid' => $uid, 'functionID' => 'clear_cache()');
                         // Returns the array of ids to clear, FALSE if nothing should be cleared! Never an empty array!
                         GeneralUtility::callUserFunction($funcName, $_params, $this);
                     }
                 }
                 // Delete cache for selected pages:
                 foreach ($pageIdsThatNeedCacheFlush as $pageId) {
                     // Workspaces always use "-1" as the page id which do not
                     // point to real pages and caches at all. Flushing caches for
                     // those records does not make sense and decreases performance
                     if ($pageId >= 0) {
                         $tagsToClear['pageId_' . $pageId] = true;
                     }
                 }
                 // Queue delete cache for current table and record
                 $tagsToClear[$table] = true;
                 $tagsToClear[$table . '_' . $uid] = true;
             }
             // Clear cache for pages entered in TSconfig:
             if (!empty($TSConfig['clearCacheCmd'])) {
                 $commands = GeneralUtility::trimExplode(',', $TSConfig['clearCacheCmd'], true);
                 $clearCacheCommands = array_unique($commands);
                 unset($commands);
             }
             // Call post processing function for clear-cache:
             if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearCachePostProc'])) {
                 $_params = array('table' => $table, 'uid' => $uid, 'uid_page' => $pageUid, 'TSConfig' => $TSConfig);
                 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearCachePostProc'] as $_funcRef) {
                     GeneralUtility::callUserFunction($_funcRef, $_params, $this);
                 }
             }
         }
     }
     /** @var CacheManager $cacheManager */
     $cacheManager = $this->getCacheManager();
     foreach ($tagsToClear as $tag => $_) {
         $cacheManager->flushCachesInGroupByTag('pages', $tag);
     }
     // Execute collected clear cache commands from page TSConfig
     foreach ($clearCacheCommands as $command) {
         $this->clear_cacheCmd($command);
     }
     // Reset the cache clearing array
     static::$recordsToClearCacheFor = array();
 }
コード例 #2
0
ファイル: DataHandler.php プロジェクト: vip3out/TYPO3.CMS
 /**
  * Do the actual clear cache
  * @return void
  */
 protected function processClearCacheQueue()
 {
     $tagsToClear = array();
     $clearCacheCommands = array();
     foreach (static::$recordsToClearCacheFor as $table => $uids) {
         foreach (array_unique($uids) as $uid) {
             if (!isset($GLOBALS['TCA'][$table]) || $uid <= 0) {
                 return;
             }
             // For move commands we may get more then 1 parent.
             $pageUids = $this->getOriginalParentOfRecord($table, $uid);
             foreach ($pageUids as $originalParent) {
                 list($tagsToClearFromPrepare, $clearCacheCommandsFromPrepare) = $this->prepareCacheFlush($table, $uid, $originalParent);
                 $tagsToClear = array_merge($tagsToClear, $tagsToClearFromPrepare);
                 $clearCacheCommands = array_merge($clearCacheCommands, $clearCacheCommandsFromPrepare);
             }
         }
     }
     /** @var CacheManager $cacheManager */
     $cacheManager = $this->getCacheManager();
     foreach ($tagsToClear as $tag => $_) {
         $cacheManager->flushCachesInGroupByTag('pages', $tag);
     }
     // Execute collected clear cache commands from page TSConfig
     foreach ($clearCacheCommands as $command) {
         $this->clear_cacheCmd($command);
     }
     // Reset the cache clearing array
     static::$recordsToClearCacheFor = array();
     // Reset the original pid array
     static::$recordPidsForDeletedRecords = array();
 }