/**
  * Truncate tables before data transfer
  *
  * @return void
  */
 private function truncateTables()
 {
     $this->databaseConnection->exec_TRUNCATEquery('tx_projectregistration_domain_model_person');
     $this->databaseConnection->exec_TRUNCATEquery('tx_projectregistration_domain_model_product');
     $this->databaseConnection->exec_TRUNCATEquery('tx_projectregistration_domain_model_productproperty');
     $this->databaseConnection->exec_TRUNCATEquery('tx_projectregistration_domain_model_productpropertyvalue');
     $this->databaseConnection->exec_TRUNCATEquery('tx_projectregistration_domain_model_project');
     $this->databaseConnection->exec_TRUNCATEquery('tx_projectregistration_product_property_mm');
     $this->feedback .= $this->renderFlashMessage('Truncated extension tables.', 'Tables truncated', FlashMessage::WARNING);
 }
Пример #2
0
 /**
  * Recursively delete cache directory and truncate all DB tables prefixed with 'cf_'
  */
 protected function forceFlushCoreFileAndDatabaseCaches()
 {
     // Delete typo3temp/Cache
     GeneralUtility::rmdir(PATH_site . 'typo3temp/Cache', TRUE);
     // Get all table names starting with 'cf_' and truncate them
     $tables = $this->databaseConnection->admin_get_tables();
     foreach ($tables as $table) {
         $tableName = $table['Name'];
         if (substr($tableName, 0, 3) === 'cf_') {
             $this->databaseConnection->exec_TRUNCATEquery($tableName);
         }
     }
 }
 /**
  * Removes all processed files and also deletes the associated physical files
  *
  * @param int|NULL $storageUid If not NULL, only the processed files of the given storage are removed
  * @return int Number of failed deletions
  */
 public function removeAll($storageUid = null)
 {
     $res = $this->databaseConnection->exec_SELECTquery('*', $this->table, 'identifier <> \'\'');
     $logger = $this->getLogger();
     $errorCount = 0;
     while ($row = $this->databaseConnection->sql_fetch_assoc($res)) {
         if ($storageUid && (int) $storageUid !== (int) $row['storage']) {
             continue;
         }
         try {
             $file = $this->createDomainObject($row);
             $file->getStorage()->setEvaluatePermissions(false);
             $file->delete(true);
         } catch (\Exception $e) {
             $logger->error('Failed to delete file "' . $row['identifier'] . '" in storage uid ' . $row['storage'] . '.', array('exception' => $e));
             ++$errorCount;
         }
     }
     $this->databaseConnection->exec_TRUNCATEquery($this->table);
     return $errorCount;
 }
Пример #4
0
 /**
  * Clears the cache based on the command $cacheCmd.
  *
  * $cacheCmd='pages'
  * Clears cache for all pages and page-based caches inside the cache manager.
  * Requires admin-flag to be set for BE_USER.
  *
  * $cacheCmd='all'
  * Clears all cache_tables. This is necessary if templates are updated.
  * Requires admin-flag to be set for BE_USER.
  *
  * The following cache_* are intentionally not cleared by 'all'
  *
  * - cache_md5params:	RDCT redirects.
  * - cache_imagesizes:	Clearing this table would cause a lot of unneeded
  * Imagemagick calls because the size informations have
  * to be fetched again after clearing.
  * - all caches inside the cache manager that are inside the group "system"
  * - they are only needed to build up the core system and templates,
  *   use "temp_cached" or "system" to do that
  *
  * $cacheCmd=[integer]
  * Clears cache for the page pointed to by $cacheCmd (an integer).
  *
  * $cacheCmd='cacheTag:[string]'
  * Flush page and pagesection cache by given tag
  *
  * $cacheCmd='cacheId:[string]'
  * Removes cache identifier from page and page section cache
  *
  * Can call a list of post processing functions as defined in
  * $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearCachePostProc']
  * (numeric array with values being the function references, called by
  * GeneralUtility::callUserFunction()).
  *
  *
  * @param string $cacheCmd The cache command, see above description
  * @return void
  */
 public function clear_cacheCmd($cacheCmd)
 {
     if (is_object($this->BE_USER)) {
         $this->BE_USER->writelog(3, 1, 0, 0, 'User %s has cleared the cache (cacheCmd=%s)', array($this->BE_USER->user['username'], $cacheCmd));
     }
     // Clear cache for either ALL pages or ALL tables!
     switch (strtolower($cacheCmd)) {
         case 'pages':
             if ($this->admin || $this->BE_USER->getTSConfigVal('options.clearCache.pages')) {
                 $this->getCacheManager()->flushCachesInGroup('pages');
             }
             break;
         case 'all':
             if ($this->admin || $this->BE_USER->getTSConfigVal('options.clearCache.all')) {
                 // Clear cache group "all" of caching framework caches
                 $this->getCacheManager()->flushCachesInGroup('all');
                 $this->databaseConnection->exec_TRUNCATEquery('cache_treelist');
             }
             break;
         case 'temp_cached':
         case 'system':
             if ($this->admin || $this->BE_USER->getTSConfigVal('options.clearCache.system') || (bool) $GLOBALS['TYPO3_CONF_VARS']['SYS']['clearCacheSystem'] === true && $this->admin) {
                 $this->getCacheManager()->flushCachesInGroup('system');
             }
             break;
     }
     $tagsToFlush = array();
     // Clear cache for a page ID!
     if (MathUtility::canBeInterpretedAsInteger($cacheCmd)) {
         $list_cache = array($cacheCmd);
         // 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' => &$list_cache, 'cacheCmd' => $cacheCmd, 'functionID' => 'clear_cacheCmd()');
                 // 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:
         if (is_array($list_cache)) {
             foreach ($list_cache as $pageId) {
                 $tagsToFlush[] = 'pageId_' . (int) $pageId;
             }
         }
     }
     // flush cache by tag
     if (GeneralUtility::isFirstPartOfStr(strtolower($cacheCmd), 'cachetag:')) {
         $cacheTag = substr($cacheCmd, 9);
         $tagsToFlush[] = $cacheTag;
     }
     // process caching framwork operations
     if (!empty($tagsToFlush)) {
         foreach (array_unique($tagsToFlush) as $tag) {
             $this->getCacheManager()->flushCachesInGroupByTag('pages', $tag);
         }
     }
     // Call post processing function for clear-cache:
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearCachePostProc'])) {
         $_params = array('cacheCmd' => strtolower($cacheCmd));
         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearCachePostProc'] as $_funcRef) {
             GeneralUtility::callUserFunction($_funcRef, $_params, $this);
         }
     }
 }
Пример #5
0
 /**
  * Resets the store by removing all data in it
  *
  * @return void
  */
 public function reset()
 {
     $this->databaseConnection->exec_TRUNCATEquery(self::ASSOCIATION_TABLE_NAME);
     $this->databaseConnection->exec_TRUNCATEquery(self::NONCE_TABLE_NAME);
 }
Пример #6
0
 /**
  * Empties the URL cache.
  *
  * @return mixed
  */
 public function clearUrlCache()
 {
     $this->databaseConnection->exec_TRUNCATEquery('tx_realurl_urlcache');
     $this->databaseConnection->exec_TRUNCATEquery('tx_realurl_uniqalias_cache_map');
 }
Пример #7
0
 public function purge($simulate)
 {
     $this->output->info('Purge deleted');
     $this->purgeDeleted('sys_file_reference', $simulate);
     $this->db->exec_DELETEquery('sys_file_reference', 'tablenames = \'\' OR fieldname = \'\'');
     $delete = new PreparedStatement('DELETE FROM sys_file_reference WHERE uid = ?', 'sys_file_reference');
     $this->output->info('Purge references pointing to deleted records');
     $res = $this->db->exec_SELECTquery('*', 'sys_file_reference', '');
     $pageTools = new PageRepository();
     $pageTools->init(FALSE);
     while ($row = $this->db->sql_fetch_assoc($res)) {
         $cnt = $this->db->exec_SELECTcountRows('uid', $row['tablenames'], 'uid = ' . $row['uid_foreign'] . $pageTools->enableFields($row['tablenames']));
         if (!$cnt) {
             if ($simulate) {
                 $this->output->info('Would delete reference ' . $row['uid']);
             } else {
                 $delete->execute(array($row['uid']));
                 $this->output->info('Deleted reference ' . $row['uid']);
             }
         }
     }
     $delete->free();
     $this->output->info('Purge sys_file records with no references');
     $delete = new PreparedStatement('DELETE FROM sys_file WHERE uid = ?', 'sys_file');
     $res = $this->db->exec_SELECTquery('uid', 'sys_file', 'uid NOT IN (select uid_local from sys_file_reference group by uid_local)');
     while ($row = $this->db->sql_fetch_assoc($res)) {
         if ($simulate) {
             $this->output->info('Would delete file record %s', array($row['uid']));
         } else {
             $delete->execute(array($row['uid']));
             $this->output->info('Deleted file record <b>%s</b>', array($row['uid']));
         }
     }
     $this->output->info('Purge actual files with no record');
     $prefixRegex = '/^' . preg_quote(PATH_site, '/') . '(fileadmin|uploads)/';
     $files = new \RegexIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator(PATH_site, RecursiveDirectoryIterator::SKIP_DOTS | RecursiveDirectoryIterator::UNIX_PATHS), RecursiveIteratorIterator::LEAVES_ONLY | RecursiveIteratorIterator::CHILD_FIRST), $prefixRegex);
     $exists = new PreparedStatement('SELECT uid FROM sys_file WHERE identifier = ?', 'sys_file');
     $fileSize = 0;
     foreach ($files as $file) {
         $filename = (string) $file;
         if (!is_file($filename)) {
             continue;
         }
         $fileId = preg_replace($prefixRegex, '', $filename);
         $exists->execute(array($fileId));
         $result = $exists->fetchAll();
         if (empty($result[0]['uid'])) {
             $fileSize += filesize($filename);
             if ($simulate) {
                 $this->output->info('<i>Would delete file %s</i>', array($filename));
             } else {
                 unlink($filename);
                 $this->output->info('Delete file %s', array($filename));
             }
         }
     }
     $size = GeneralUtility::formatSize($fileSize);
     if ($simulate) {
         $this->output->info('Would delete %s of files', array($size));
         $this->output->info('Would truncate table sys_file_processedfile');
     } else {
         $this->output->info('Deleted %s of files', array($size));
         $this->db->exec_TRUNCATEquery('sys_file_processedfile');
         $this->output->info('Truncated table sys_file_processedfile');
     }
 }