コード例 #1
0
 /**
  * Clears the cache of configured pages in TypoScript
  *
  * @param array $settings The settings
  *
  * @return void
  */
 public function clearCacheForConfiguredUids($settings)
 {
     $pidList = $this->settingsService->getClearCacheUids($settings);
     if (count($pidList) > 0) {
         $this->cacheService->clearPageCache($pidList);
     }
 }
コード例 #2
0
 /**
  * The cleanup command
  *
  * @return void
  */
 public function cleanupCommand()
 {
     $fullSettings = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT, 'SfEventMgt', 'Pievent');
     $settings = $fullSettings['plugin.']['tx_sfeventmgt.']['settings.'];
     $this->registrationService->handleExpiredRegistrations($settings['registration.']['deleteExpiredRegistrations']);
     $pidList = explode(',', $settings['clearCacheUids']);
     $this->cacheService->clearPageCache($pidList);
 }
コード例 #3
0
 /**
  * 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(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
     if (isset($extbaseSettings['persistence']['enableAutomaticCacheClearing']) && $extbaseSettings['persistence']['enableAutomaticCacheClearing'] === '1') {
         if (isset($GLOBALS['TSFE'])) {
             $pageUid = $GLOBALS['TSFE']->id;
             $this->cacheService->clearPageCache(array($pageUid));
         }
     }
 }
コード例 #4
0
 /**
  * Clear the cachePageEntries of the given tt_content entries
  * 
  * @param array $ttContentEntries
  * @return count of cleared pages
  */
 protected function clearPageCacheEntries(array $ttContentEntries)
 {
     $pageIdsToClear = array();
     /* @var $ttContentEntry Tx_Yag_Domain_Model_Extern_TTContent */
     foreach ($ttContentEntries as $ttContentEntry) {
         $pageIdsToClear[] = $ttContentEntry->getPid();
     }
     $this->cacheService->clearPageCache($pageIdsToClear);
     return count($pageIdsToClear);
 }
コード例 #5
0
 /**
  * @test
  */
 public function clearsCachesOfDuplicateRegisteredPageIdsOnlyOnce()
 {
     $this->cacheManagerMock->expects($this->at(0))->method('flushCachesInGroupByTag')->with('pages', 'pageId_2');
     $this->cacheManagerMock->expects($this->at(1))->method('flushCachesInGroupByTag')->with('pages', 'pageId_15');
     $this->cacheManagerMock->expects($this->at(2))->method('flushCachesInGroupByTag')->with('pages', 'pageId_8');
     $this->cacheManagerMock->expects($this->exactly(3))->method('flushCachesInGroupByTag');
     $this->cacheService->getPageIdStack()->push(8);
     $this->cacheService->getPageIdStack()->push(15);
     $this->cacheService->getPageIdStack()->push(15);
     $this->cacheService->getPageIdStack()->push(2);
     $this->cacheService->getPageIdStack()->push(2);
     $this->cacheService->clearCachesOfRegisteredPageIds();
 }
コード例 #6
0
 /**
  * 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 DataHandler::clear_cache() which unfortunately only works with logged-in BE user.
  *
  * @param string $tableName Table name of the record
  * @param int $uid UID of the record
  * @return void
  */
 protected function clearPageCache($tableName, $uid)
 {
     $frameworkConfiguration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
     if (isset($frameworkConfiguration['persistence']['enableAutomaticCacheClearing']) && $frameworkConfiguration['persistence']['enableAutomaticCacheClearing'] === '1') {
     } else {
         // if disabled, return
         return;
     }
     $pageIdsToClear = [];
     $storagePage = null;
     $columns = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable($tableName)->getSchemaManager()->listTableColumns($tableName);
     if (array_key_exists('pid', $columns)) {
         $queryBuilder = $this->connectionPool->getQueryBuilderForTable($tableName);
         $queryBuilder->getRestrictions()->removeAll();
         $result = $queryBuilder->select('pid')->from($tableName)->where($queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)))->execute();
         if ($row = $result->fetch()) {
             $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] = BackendUtility::getPagesTSconfig($storagePage);
     }
     if (isset($this->pageTSConfigCache[$storagePage]['TCEMAIN.']['clearCacheCmd'])) {
         $clearCacheCommands = GeneralUtility::trimExplode(',', strtolower($this->pageTSConfigCache[$storagePage]['TCEMAIN.']['clearCacheCmd']), true);
         $clearCacheCommands = array_unique($clearCacheCommands);
         foreach ($clearCacheCommands as $clearCacheCommand) {
             if (MathUtility::canBeInterpretedAsInteger($clearCacheCommand)) {
                 $pageIdsToClear[] = $clearCacheCommand;
             }
         }
     }
     foreach ($pageIdsToClear as $pageIdToClear) {
         $this->cacheService->getPageIdStack()->push($pageIdToClear);
     }
 }
コード例 #7
0
 /**
  * Saves the registration
  *
  * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registration Registration
  * @param \DERHANSEN\SfEventMgt\Domain\Model\Event $event Event
  * @validate $registration \DERHANSEN\SfEventMgt\Validation\Validator\RegistrationValidator
  *
  * @return void
  */
 public function saveRegistrationAction(Registration $registration, Event $event)
 {
     $autoConfirmation = (bool) $this->settings['registration']['autoConfirmation'];
     $result = RegistrationResult::REGISTRATION_SUCCESSFUL;
     $success = $this->checkRegistrationSuccess($event, $registration, $result);
     // Save registration if no errors
     if ($success) {
         $linkValidity = (int) $this->settings['confirmation']['linkValidity'];
         if ($linkValidity === 0) {
             // Use 3600 seconds as default value if not set
             $linkValidity = 3600;
         }
         $confirmationUntil = new \DateTime();
         $confirmationUntil->add(new \DateInterval('PT' . $linkValidity . 'S'));
         $registration->setEvent($event);
         $registration->setPid($event->getPid());
         $registration->setConfirmationUntil($confirmationUntil);
         $registration->_setProperty('_languageUid', $GLOBALS['TSFE']->sys_language_uid);
         $this->registrationRepository->add($registration);
         // Persist registration, so we have an UID
         $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager')->persistAll();
         // Send notifications to user and admin if confirmation link should be sent
         if (!$autoConfirmation) {
             $this->notificationService->sendUserMessage($event, $registration, $this->settings, MessageType::REGISTRATION_NEW);
             $this->notificationService->sendAdminMessage($event, $registration, $this->settings, MessageType::REGISTRATION_NEW);
         }
         // Create given amount of registrations if necessary
         if ($registration->getAmountOfRegistrations() > 1) {
             $this->registrationService->createDependingRegistrations($registration);
         }
         // Clear cache for configured pages
         $pidList = $this->settingsService->getClearCacheUids($this->settings);
         if (count($pidList) > 0) {
             $this->cacheService->clearPageCache($pidList);
         }
     }
     if ($autoConfirmation && $success) {
         $this->redirect('confirmRegistration', NULL, NULL, array('reguid' => $registration->getUid(), 'hmac' => $this->hashService->generateHmac('reg-' . $registration->getUid())));
     } else {
         $this->redirect('saveRegistrationResult', NULL, NULL, array('result' => $result));
     }
 }
コード例 #8
0
ファイル: Typo3DbBackend.php プロジェクト: plan2net/TYPO3.CMS
 /**
  * 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 DataHandler::clear_cache() which unfortunately only works with logged-in BE user.
  *
  * @param string $tableName Table name of the record
  * @param int $uid UID of the record
  * @return void
  */
 protected function clearPageCache($tableName, $uid)
 {
     $frameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
     if (isset($frameworkConfiguration['persistence']['enableAutomaticCacheClearing']) && $frameworkConfiguration['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=' . (int) $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] = BackendUtility::getPagesTSconfig($storagePage);
     }
     if (isset($this->pageTSConfigCache[$storagePage]['TCEMAIN.']['clearCacheCmd'])) {
         $clearCacheCommands = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', strtolower($this->pageTSConfigCache[$storagePage]['TCEMAIN.']['clearCacheCmd']), TRUE);
         $clearCacheCommands = array_unique($clearCacheCommands);
         foreach ($clearCacheCommands as $clearCacheCommand) {
             if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($clearCacheCommand)) {
                 $pageIdsToClear[] = $clearCacheCommand;
             }
         }
     }
     foreach ($pageIdsToClear as $pageIdToClear) {
         $this->cacheService->getPageIdStack()->push($pageIdToClear);
     }
 }
コード例 #9
0
 /**
  * Helper function for flush frontend page cache
  *
  * Needed as we want to make sure new comments are visible after enabling in BE.
  *
  * @return void
  */
 protected function flushFrontendCache()
 {
     if (TYPO3_MODE === 'BE' && !empty($this->settings['blogsystem']['pid'])) {
         $this->cacheService->clearPageCache((int) $this->settings['blogsystem']['pid']);
     }
 }