/**
  * This clear cache implementation follows a pretty brutal approach.
  * Goal is to reliably get rid of cache entries, even if some broken
  * extension is loaded that would kill the backend 'clear cache' action.
  *
  * Therefor this method "knows" implementation details of the cache
  * framework and uses them to clear all file based cache (typo3temp/Cache)
  * and database caches (tables prefixed with cf_) manually.
  *
  * After that ext_tables and ext_localconf of extensions are loaded, those
  * may register additional caches in the caching framework with different
  * backend, and will then clear them with the usual flush() method.
  *
  * @return void
  */
 public function clearAll()
 {
     // Delete typo3temp/Cache
     GeneralUtility::rmdir(PATH_site . 'typo3temp/Cache', TRUE);
     $bootstrap = \TYPO3\CMS\Core\Core\Bootstrap::getInstance();
     $bootstrap->unregisterClassLoader();
     \TYPO3\CMS\Core\Cache\Cache::flagCachingFrameworkForReinitialization();
     $bootstrap->initializeClassLoader()->initializeCachingFramework()->initializeClassLoaderCaches()->initializePackageManagement('TYPO3\\CMS\\Core\\Package\\PackageManager');
     // Get all table names starting with 'cf_' and truncate them
     $database = $this->getDatabaseConnection();
     $tables = $database->admin_get_tables();
     foreach ($tables as $table) {
         $tableName = $table['Name'];
         if (substr($tableName, 0, 3) === 'cf_') {
             $database->exec_TRUNCATEquery($tableName);
         }
     }
     // From this point on, the code may fatal, if some broken extension is loaded.
     // Use bootstrap to load all ext_localconf and ext_tables
     $bootstrap->loadTypo3LoadedExtAndExtLocalconf(FALSE)->applyAdditionalConfigurationSettings()->initializeTypo3DbGlobal()->loadExtensionTables(FALSE);
     // The cache manager is already instantiated in the install tool
     // with some hacked settings to disable caching of extbase and fluid.
     // We want a "fresh" object here to operate on a different cache setup.
     // cacheManager implements SingletonInterface, so the only way to get a "fresh"
     // instance is by circumventing makeInstance and/or the objectManager and
     // using new directly!
     $cacheManager = new \TYPO3\CMS\Core\Cache\CacheManager();
     $cacheManager->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
     // Cache manager needs cache factory. cache factory injects itself to manager in __construct()
     new \TYPO3\CMS\Core\Cache\CacheFactory('production', $cacheManager);
     $cacheManager->flushCaches();
 }
 /**
  * @return void
  */
 protected function importCacheTables()
 {
     if (\TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) >= 4006000) {
         $cacheTables = \TYPO3\CMS\Core\Cache\Cache::getDatabaseTableDefinitions();
         $this->importDatabaseDefinitions($cacheTables);
     }
 }
 /**
  * Initialize cache instance to be ready to use
  *
  * @return void
  */
 protected function initializeCache()
 {
     Cache::initializeCachingFramework();
     try {
         $this->cacheInstance = $GLOBALS['typo3CacheManager']->getCache('sfbanners_cache');
     } catch (NoSuchCacheException $e) {
         $this->cacheInstance = $GLOBALS['typo3CacheFactory']->create('sfbanners_cache', $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['sfbanners_cache']['frontend'], $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['sfbanners_cache']['backend'], $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['sfbanners_cache']['options']);
     }
 }
 /**
  * Initialize cache instance to be ready to use
  *
  * @return void
  */
 protected function initializeCache()
 {
     \TYPO3\CMS\Core\Cache\Cache::initializeCachingFramework();
     try {
         $this->cacheInstance = $GLOBALS['typo3CacheManager']->getCache('sharepointconnector_lists');
     } catch (\TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException $e) {
         $this->cacheInstance = $GLOBALS['typo3CacheFactory']->create('sharepointconnector_lists', $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['sharepointconnector_lists']['frontend'], $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['sharepointconnector_lists']['backend'], $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['sharepointconnector_lists']['options']);
     }
 }
 /**
  * Initialize cache instance to be ready to use
  *
  * @return void
  */
 protected function initializeCache()
 {
     if (static::$cacheInstance == null) {
         \TYPO3\CMS\Core\Cache\Cache::initializeCachingFramework();
         try {
             static::$cacheInstance = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager')->getCache('mak_dataviewhelpers');
         } catch (\TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException $e) {
             static::$cacheInstance = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Cache\\CacheFactory')->create('mak_fs', $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['mak_dataviewhelpers']['frontend'], $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['mak_dataviewhelpers']['backend'], $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['mak_dataviewhelpers']['options']);
         }
     }
 }
Exemple #6
0
 public static function clearCache()
 {
     if (\TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) >= 7005000) {
         $pageCache = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager')->getCache('cache_pages');
         $pageCache->flushByTag('cal');
     } else {
         // only use cachingFramework if initialized and configured in TYPO3
         if (\TYPO3\CMS\Core\Cache\Cache::isCachingFrameworkInitialized() && TYPO3_UseCachingFramework && is_object($GLOBALS['typo3CacheManager'])) {
             $pageCache = $GLOBALS['typo3CacheManager']->getCache('cache_pages');
             $pageCache->flushByTag('cal');
         }
     }
 }
 /**
  * @return string
  */
 protected function resolveTableDefinitions()
 {
     $tableDefinitions = '';
     foreach ($GLOBALS['TYPO3_LOADED_EXT'] as $loadedExtConf) {
         if (is_array($loadedExtConf) && $loadedExtConf['ext_tables.sql']) {
             $extensionSqlContent = \TYPO3\CMS\Core\Utility\GeneralUtility::getUrl($loadedExtConf['ext_tables.sql']);
             $tableDefinitions .= PHP_EOL . PHP_EOL . PHP_EOL . PHP_EOL . $extensionSqlContent;
         }
     }
     // Add SQL content coming from the caching framework
     $tableDefinitions .= \TYPO3\CMS\Core\Cache\Cache::getDatabaseTableDefinitions();
     // Add SQL content coming from the category registry
     $tableDefinitions .= \TYPO3\CMS\Core\Category\CategoryRegistry::getInstance()->getDatabaseTableDefinitions();
     return $tableDefinitions;
 }
 /**
  * Get schema SQL of required cache framework tables.
  *
  * This method needs ext_localconf and ext_tables loaded!
  *
  * This is a hack, but there was no smarter solution with current cache configuration setup:
  * ToolController sets the extbase caches to NullBackend to ensure the install tool does not
  * cache anything. The CacheManager gets the required SQL from database backends only, so we need to
  * temporarily 'fake' the standard db backends for extbase caches so they are respected.
  *
  * Additionally, the extbase_object cache is already in use and instantiated, and the CacheManager singleton
  * does not allow overriding this definition. The only option at the moment is to 'fake' another cache with
  * a different name, and then substitute this name in the sql content with the real one.
  *
  * @TODO: http://forge.typo3.org/issues/54498
  * @TODO: It might be possible to reduce this ugly construct by circumventing the 'singleton' of CacheManager by using 'new'
  *
  * @return string Cache framework SQL
  */
 public function getCachingFrameworkRequiredDatabaseSchema()
 {
     $cacheConfigurationBackup = $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'];
     $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_datamapfactory_datamap'] = array('groups' => array('system'));
     $extbaseObjectFakeName = uniqid('extbase_object');
     $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$extbaseObjectFakeName] = array('groups' => array('system'));
     $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_reflection'] = array('groups' => array('system'));
     $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_typo3dbbackend_tablecolumns'] = array('groups' => array('system'));
     /** @var \TYPO3\CMS\Core\Cache\CacheManager $cacheManager */
     $cacheManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager');
     $cacheManager->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
     $cacheSqlString = \TYPO3\CMS\Core\Cache\Cache::getDatabaseTableDefinitions();
     $sqlString = str_replace($extbaseObjectFakeName, 'extbase_object', $cacheSqlString);
     $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'] = $cacheConfigurationBackup;
     $cacheManager->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
     return $sqlString;
 }
Exemple #9
0
 /**
  * Returns the cache object for the context
  *
  * @param \MShop_Context_Item_Interface $context Context object including config
  * @param string $siteid Unique site ID
  * @return \MW_Cache_Interface Cache object
  */
 protected static function getCache(\MShop_Context_Item_Interface $context)
 {
     $config = $context->getConfig();
     switch (Base::getExtConfig('cacheName', 'Typo3')) {
         case 'None':
             $config->set('client/html/basket/cache/enable', false);
             return \MW_Cache_Factory::createManager('None', array(), null);
         case 'Typo3':
             if (class_exists('\\TYPO3\\CMS\\Core\\Cache\\Cache')) {
                 \TYPO3\CMS\Core\Cache\Cache::initializeCachingFramework();
             }
             $manager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager');
             return new \MAdmin_Cache_Proxy_Typo3($context, $manager->getCache('aimeos'));
         default:
             return new \MAdmin_Cache_Proxy_Default($context);
     }
 }
Exemple #10
0
 /**
  * @param ConsoleBootstrap $bootstrap
  */
 public static function initializeCachingFramework(ConsoleBootstrap $bootstrap)
 {
     // Cache framework initialisation for TYPO3 CMS <= 7.3
     if (class_exists('TYPO3\\CMS\\Core\\Cache\\Cache')) {
         $bootstrap->setEarlyInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager', \TYPO3\CMS\Core\Cache\Cache::initializeCachingFramework());
         // @deprecated since 6.2 will be removed in two versions
         if (class_exists('TYPO3\\CMS\\Core\\Compatibility\\GlobalObjectDeprecationDecorator')) {
             $GLOBALS['typo3CacheManager'] = new \TYPO3\CMS\Core\Compatibility\GlobalObjectDeprecationDecorator('TYPO3\\CMS\\Core\\Cache\\CacheManager');
             $GLOBALS['typo3CacheFactory'] = new \TYPO3\CMS\Core\Compatibility\GlobalObjectDeprecationDecorator('TYPO3\\CMS\\Core\\Cache\\CacheFactory');
         }
     } else {
         $cacheManager = new \TYPO3\CMS\Core\Cache\CacheManager();
         $cacheManager->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
         \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance(\TYPO3\CMS\Core\Cache\CacheManager::class, $cacheManager);
         $cacheFactory = new \TYPO3\CMS\Core\Cache\CacheFactory('production', $cacheManager);
         \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance(\TYPO3\CMS\Core\Cache\CacheFactory::class, $cacheFactory);
         $bootstrap->setEarlyInstance(\TYPO3\CMS\Core\Cache\CacheManager::class, $cacheManager);
     }
 }
Exemple #11
0
<?php

if (!defined('TYPO3_MODE')) {
    die('Access denied.');
}
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin($_EXTKEY, 'Pi1', 'LLL:EXT:' . $_EXTKEY . '/Resources/Private/Language/locallang.xml:plugin_title');
/* Add Flexform */
$extensionName = t3lib_div::underscoredToUpperCamelCase($_EXTKEY);
$pluginSignature = strtolower($extensionName) . '_pi1';
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform';
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue($pluginSignature, 'FILE:EXT:' . $_EXTKEY . '/Configuration/Flexforms/Flexform_plugin.xml');
/* Remove unused fields */
$TCA['tt_content']['types']['list']['subtypes_excludelist'][$pluginSignature] = 'layout,recursive,select_key';
/* Add default Typoscript */
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile($_EXTKEY, 'Configuration/TypoScript', 'Banner Management');
if (TYPO3_MODE == 'BE') {
    /* Add Plugin to wizzard */
    $TBE_MODULES_EXT['xMOD_db_new_content_el']['addElClasses'][$pluginSignature . '_wizicon'] = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'Resources/Private/Php/class.' . $_EXTKEY . '_wizicon.php';
    /* register the cache in BE so it will be cleared with "clear all caches" */
    if (\TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) < '4006000') {
        \TYPO3\CMS\Core\Cache\Cache::initializeCachingFramework();
        $GLOBALS['typo3CacheFactory']->create('sfbanners_cache', $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['sfbanners_cache']['frontend'], $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['sfbanners_cache']['backend'], $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['sfbanners_cache']['options']);
    }
}
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr('tx_sfbanners_domain_model_category', 'EXT:sf_banners/Resources/Private/Language/locallang_csh_tx_sfbanners_domain_model_category.xml');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('tx_sfbanners_domain_model_category');
$TCA['tx_sfbanners_domain_model_category'] = array('ctrl' => array('title' => 'LLL:EXT:sf_banners/Resources/Private/Language/locallang_db.xml:tx_sfbanners_domain_model_category', 'label' => 'title', 'tstamp' => 'tstamp', 'crdate' => 'crdate', 'cruser_id' => 'cruser_id', 'dividers2tabs' => TRUE, 'sortby' => 'sorting', 'versioningWS' => 2, 'versioning_followPages' => TRUE, 'origUid' => 't3_origuid', 'languageField' => 'sys_language_uid', 'transOrigPointerField' => 'l10n_parent', 'transOrigDiffSourceField' => 'l10n_diffsource', 'delete' => 'deleted', 'enablecolumns' => array('disabled' => 'hidden', 'starttime' => 'starttime', 'endtime' => 'endtime'), 'searchFields' => 'title,parent,', 'dynamicConfigFile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'Configuration/TCA/Category.php', 'iconfile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($_EXTKEY) . 'Resources/Public/Icons/tx_sfbanners_domain_model_category.gif'));
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr('tx_sfbanners_domain_model_banner', 'EXT:sf_banners/Resources/Private/Language/locallang_csh_tx_sfbanners_domain_model_banner.xml');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('tx_sfbanners_domain_model_banner');
$TCA['tx_sfbanners_domain_model_banner'] = array('ctrl' => array('title' => 'LLL:EXT:sf_banners/Resources/Private/Language/locallang_db.xml:tx_sfbanners_domain_model_banner', 'label' => 'title', 'tstamp' => 'tstamp', 'crdate' => 'crdate', 'cruser_id' => 'cruser_id', 'type' => 'type', 'dividers2tabs' => TRUE, 'sortby' => 'sorting', 'versioningWS' => 2, 'versioning_followPages' => TRUE, 'origUid' => 't3_origuid', 'languageField' => 'sys_language_uid', 'transOrigPointerField' => 'l10n_parent', 'transOrigDiffSourceField' => 'l10n_diffsource', 'delete' => 'deleted', 'enablecolumns' => array('disabled' => 'hidden', 'starttime' => 'starttime', 'endtime' => 'endtime'), 'searchFields' => 'title,description,type,category,', 'dynamicConfigFile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'Configuration/TCA/Banner.php', 'iconfile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($_EXTKEY) . 'Resources/Public/Icons/tx_sfbanners_domain_model_banner.gif'));
 /**
  * Gets the content of the ext_tables.sql and ext_tables_static+adt.sql files
  * Additionally adds the table definitions for the cache tables
  *
  * @param string $extension
  * @return void
  */
 public function processDatabaseUpdates($extension)
 {
     $extTablesSqlFile = PATH_site . $extension['siteRelPath'] . '/ext_tables.sql';
     if (file_exists($extTablesSqlFile)) {
         $extTablesSqlContent = \TYPO3\CMS\Core\Utility\GeneralUtility::getUrl($extTablesSqlFile);
         // @TODO: This should probably moved to TYPO3\CMS\Core\Cache\Cache->getDatabaseTableDefinitions ?!
         $GLOBALS['typo3CacheManager']->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
         $extTablesSqlContent .= \TYPO3\CMS\Core\Cache\Cache::getDatabaseTableDefinitions();
         $this->updateDbWithExtTablesSql($extTablesSqlContent);
     }
     $extTablesStaticSqlFile = PATH_site . $extension['siteRelPath'] . '/ext_tables_static+adt.sql';
     if (file_exists($extTablesStaticSqlFile)) {
         $extTablesStaticSqlContent = \TYPO3\CMS\Core\Utility\GeneralUtility::getUrl($extTablesStaticSqlFile);
         $this->importStaticSql($extTablesStaticSqlContent);
     }
 }
Exemple #13
0
 /**
  * Initialize caching framework
  *
  * @return \TYPO3\CMS\Core\Core\Bootstrap
  */
 protected function initializeCachingFramework()
 {
     \TYPO3\CMS\Core\Cache\Cache::initializeCachingFramework();
     return $this;
 }
 /**
  * Loop through caching configurations
  * to find the usage of database backends and
  * parse and analyze table definitions
  *
  * @return void
  */
 protected function analyzeCachingTables()
 {
     $this->parseAndAnalyzeSql(\TYPO3\CMS\Core\Cache\Cache::getDatabaseTableDefinitions());
 }
Exemple #15
0
 /**
  * Generates update wizard
  *
  * @return void
  * @todo Define visibility
  */
 public function updateWizard()
 {
     \TYPO3\CMS\Core\Extension\ExtensionManager::removeCacheFiles();
     // Forces creation / update of caching framework tables that are needed by some update wizards
     $cacheTablesConfiguration = implode(LF, $this->sqlHandler->getStatementArray(\TYPO3\CMS\Core\Cache\Cache::getDatabaseTableDefinitions(), 1, '^CREATE TABLE '));
     $neededTableDefinition = $this->sqlHandler->getFieldDefinitions_fileContent($cacheTablesConfiguration);
     $currentTableDefinition = $this->sqlHandler->getFieldDefinitions_database();
     $updateTableDefenition = $this->sqlHandler->getDatabaseExtra($neededTableDefinition, $currentTableDefinition);
     $updateStatements = $this->sqlHandler->getUpdateSuggestions($updateTableDefenition);
     if (isset($updateStatements['create_table']) && count($updateStatements['create_table']) > 0) {
         $this->sqlHandler->performUpdateQueries($updateStatements['create_table'], $updateStatements['create_table']);
     }
     if (isset($updateStatements['add']) && count($updateStatements['add']) > 0) {
         $this->sqlHandler->performUpdateQueries($updateStatements['add'], $updateStatements['add']);
     }
     if (isset($updateStatements['change']) && count($updateStatements['change']) > 0) {
         $this->sqlHandler->performUpdateQueries($updateStatements['change'], $updateStatements['change']);
     }
     // call wizard
     $action = $this->INSTALL['database_type'] ? $this->INSTALL['database_type'] : 'checkForUpdate';
     $this->updateWizard_parts($action);
     $this->output($this->outputWrapper($this->printAll()));
 }
 /**
  * @param ConsoleBootstrap $bootstrap
  */
 public static function initializeCachingFramework(ConsoleBootstrap $bootstrap)
 {
     $bootstrap->setEarlyInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager', \TYPO3\CMS\Core\Cache\Cache::initializeCachingFramework());
     // @deprecated since 6.2 will be removed in two versions
     if (class_exists('TYPO3\\CMS\\Core\\Compatibility\\GlobalObjectDeprecationDecorator')) {
         $GLOBALS['typo3CacheManager'] = new \TYPO3\CMS\Core\Compatibility\GlobalObjectDeprecationDecorator('TYPO3\\CMS\\Core\\Cache\\CacheManager');
         $GLOBALS['typo3CacheFactory'] = new \TYPO3\CMS\Core\Compatibility\GlobalObjectDeprecationDecorator('TYPO3\\CMS\\Core\\Cache\\CacheFactory');
     }
 }
 /**
  * Gets the defined field definitions from the ext_tables.sql files.
  *
  * @return array The accordant definitions
  */
 protected function getDefinedFieldDefinitions()
 {
     $content = '';
     $cacheTables = '';
     if (class_exists('t3lib_cache') && method_exists(t3lib_cache, 'getDatabaseTableDefinitions')) {
         $cacheTables = \TYPO3\CMS\Core\Cache\Cache::getDatabaseTableDefinitions();
     }
     if (method_exists($this->install, 'getFieldDefinitions_fileContent')) {
         $content = $this->install->getFieldDefinitions_fileContent(implode(chr(10), $this->getAllRawStructureDefinitions()) . $cacheTables);
     } else {
         $content = $this->install->getFieldDefinitions_sqlContent(implode(chr(10), $this->getAllRawStructureDefinitions()) . $cacheTables);
     }
     return $content;
 }
Exemple #18
0
 /**
  * Initialize caching framework
  *
  * @return Bootstrap
  * @internal This is not a public API method, do not use in own extensions
  */
 public function initializeCachingFramework()
 {
     $this->setEarlyInstance(\TYPO3\CMS\Core\Cache\CacheManager::class, \TYPO3\CMS\Core\Cache\Cache::initializeCachingFramework());
     return $this;
 }
 /**
  * @param string $extKey
  * @return void
  */
 public function checkForDbUpdate($extensionKey)
 {
     $this->dbUpdateNeeded = FALSE;
     if (ExtensionManagementUtility::isLoaded($extensionKey)) {
         $sqlFile = ExtensionManagementUtility::extPath($extensionKey) . 'ext_tables.sql';
         if (@file_exists($sqlFile)) {
             $this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
             if (class_exists('TYPO3\\CMS\\Install\\Service\\SqlSchemaMigrationService')) {
                 /* @var \TYPO3\CMS\Install\Service\SqlSchemaMigrationService $sqlHandler */
                 $sqlHandler = $this->objectManager->get('TYPO3\\CMS\\Install\\Service\\SqlSchemaMigrationService');
             } else {
                 /* @var \TYPO3\CMS\Install\Sql\SchemaMigrator $sqlHandler */
                 $sqlHandler = $this->objectManager->get('TYPO3\\CMS\\Install\\Sql\\SchemaMigrator');
             }
             $sqlContent = \TYPO3\CMS\Core\Utility\GeneralUtility::getUrl($sqlFile);
             /** @var $cacheManager \TYPO3\CMS\Core\Cache\CacheManager */
             $cacheManager = $GLOBALS['typo3CacheManager'];
             $cacheManager->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
             $sqlContent .= \TYPO3\CMS\Core\Cache\Cache::getDatabaseTableDefinitions();
             $fieldDefinitionsFromFile = $sqlHandler->getFieldDefinitions_fileContent($sqlContent);
             if (count($fieldDefinitionsFromFile)) {
                 $fieldDefinitionsFromCurrentDatabase = $sqlHandler->getFieldDefinitions_database();
                 $updateTableDefinition = $sqlHandler->getDatabaseExtra($fieldDefinitionsFromFile, $fieldDefinitionsFromCurrentDatabase);
                 $this->updateStatements = $sqlHandler->getUpdateSuggestions($updateTableDefinition);
                 if (!empty($updateTableDefinition['extra']) || !empty($updateTableDefinition['diff']) || !empty($updateTableDefinition['diff_currentValues'])) {
                     $this->dbUpdateNeeded = TRUE;
                 }
             }
         }
     }
 }
Exemple #20
0
 /**
  * Imports the data from the stddb tables.sql file.
  *
  * Example/intended usage:
  *
  * <pre>
  * protected function setUp() {
  *   $this->createDatabase();
  *   $db = $this->useTestDatabase();
  *   $this->importStdDB();
  *   $this->importExtensions(array('cms', 'static_info_tables', 'templavoila'));
  * }
  * </pre>
  *
  * @return void
  */
 protected function importStdDb()
 {
     /* @var TYPO3\CMS\Extbase\Object\ObjectManager $objectManager */
     $objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
     /** @var TYPO3\CMS\Install\Service\SqlExpectedSchemaService $sqlExpectedSchemaService */
     $sqlExpectedSchemaService = $objectManager->get('TYPO3\\CMS\\Install\\Service\\SqlExpectedSchemaService');
     $databaseDefinitions = $sqlExpectedSchemaService->getTablesDefinitionString(TRUE);
     $this->importDatabaseDefinitions($databaseDefinitions);
     // make sure missing caching framework tables do not get into the way
     $cacheTables = Cache::getDatabaseTableDefinitions();
     $this->importDatabaseDefinitions($cacheTables);
 }
Exemple #21
0
 /**
  * Initialize caching framework
  *
  * @return Bootstrap
  * @internal This is not a public API method, do not use in own extensions
  */
 public function initializeCachingFramework()
 {
     $this->setEarlyInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager', \TYPO3\CMS\Core\Cache\Cache::initializeCachingFramework());
     // @deprecated since 6.2 will be removed in two versions
     $GLOBALS['typo3CacheManager'] = new \TYPO3\CMS\Core\Compatibility\GlobalObjectDeprecationDecorator('TYPO3\\CMS\\Core\\Cache\\CacheManager');
     $GLOBALS['typo3CacheFactory'] = new \TYPO3\CMS\Core\Compatibility\GlobalObjectDeprecationDecorator('TYPO3\\CMS\\Core\\Cache\\CacheFactory');
     return $this;
 }
 /**
  * Get the update statement of the database
  *
  * @return array
  */
 public static function getSqlUpdateStatements()
 {
     $tblFileContent = \TYPO3\CMS\Core\Utility\GeneralUtility::getUrl(PATH_typo3 . 'sysext/core/ext_tables.sql');
     foreach ($GLOBALS['TYPO3_LOADED_EXT'] as $loadedExtConf) {
         if (is_array($loadedExtConf) && $loadedExtConf['ext_tables.sql']) {
             $tblFileContent .= chr(10) . chr(10) . chr(10) . chr(10) . \TYPO3\CMS\Core\Utility\GeneralUtility::getUrl($loadedExtConf['ext_tables.sql']);
         }
     }
     if (class_exists('\\TYPO3\\CMS\\Core\\Category\\CategoryRegistry') && version_compare(TYPO3_version, '7.6.0', '>=')) {
         $tblFileContent .= \TYPO3\CMS\Core\Category\CategoryRegistry::getInstance()->getDatabaseTableDefinitions();
         $tableDefinitions = \TYPO3\CMS\Core\Category\CategoryRegistry::getInstance()->addCategoryDatabaseSchemaToTablesDefinition(array());
         $tblFileContent .= $tableDefinitions['sqlString '];
         $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
         $cachingFrameworkDatabaseSchemaService = $objectManager->get('TYPO3\\CMS\\Core\\Cache\\DatabaseSchemaService');
         $tableDefinitionsCache = $cachingFrameworkDatabaseSchemaService->addCachingFrameworkRequiredDatabaseSchemaForSqlExpectedSchemaService(array());
         $tblFileContent .= implode(LF, $tableDefinitionsCache[0]);
     } else {
         $tblFileContent .= \TYPO3\CMS\Core\Cache\Cache::getDatabaseTableDefinitions();
     }
     $installClass = self::getInstallSqlClass();
     $instObj = new $installClass();
     $fdDb = self::getDatabaseSchema();
     if ($tblFileContent) {
         $fileContent = implode(chr(10), $instObj->getStatementArray($tblFileContent, 1, '^CREATE TABLE '));
         // just support for old version
         if (method_exists($installClass, 'getFieldDefinitions_fileContent') === true) {
             $fdFile = $instObj->getFieldDefinitions_fileContent($fileContent);
         } else {
             $fdFile = $instObj->getFieldDefinitions_sqlContent($fileContent);
         }
         $diff = $instObj->getDatabaseExtra($fdFile, $fdDb);
         $updateStatements = $instObj->getUpdateSuggestions($diff);
         $diff = $instObj->getDatabaseExtra($fdDb, $fdFile);
         $removeStatements = $instObj->getUpdateSuggestions($diff, 'remove');
         return array('update' => $updateStatements, 'remove' => $removeStatements);
     } else {
         return array('update' => null, 'remove' => null);
     }
 }