Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX] Do not call unavailable bootstrap method #494

Merged
merged 1 commit into from
May 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion Classes/Core/Booting/Scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,13 @@ public static function initializeExtensionConfiguration(ConsoleBootstrap $bootst
*/
public static function initializePersistence(ConsoleBootstrap $bootstrap)
{
$bootstrap->loadExtensionTables();
if (is_callable([$bootstrap, 'loadExtTables'])) {
$bootstrap->loadBaseTca();
$bootstrap->loadExtTables();
} else {
// @deprecated can be removed once TYPO3 7.6 support is removed
$bootstrap->loadExtensionTables();
}
}

/**
Expand Down
5 changes: 4 additions & 1 deletion Classes/Core/ConsoleBootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,10 @@ public function initializeDatabaseConnection()
if (is_callable([$this, 'defineDatabaseConstants'])) {
$this->defineDatabaseConstants();
}
$this->initializeTypo3DbGlobal();
// @deprecated can be removed if TYPO3 7 support is removed
if (is_callable([$this, 'initializeTypo3DbGlobal'])) {
$this->initializeTypo3DbGlobal();
}
}

protected function flushOutputBuffers()
Expand Down
55 changes: 38 additions & 17 deletions Classes/Service/CacheService.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\Cache\Exception\NoSuchCacheGroupException;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\DatabaseConnection;
use TYPO3\CMS\Core\DataHandling\DataHandler;
use TYPO3\CMS\Core\SingletonInterface;
Expand All @@ -37,26 +38,16 @@ class CacheService implements SingletonInterface
*/
protected $configurationService;

/**
* @var DatabaseConnection
*/
protected $databaseConnection;

/**
* Builds the dependencies correctly
*
* @param CacheManager $cacheManager
* @param ConfigurationService $configurationService
* @param DatabaseConnection $databaseConnection
*/
public function __construct(
CacheManager $cacheManager,
ConfigurationService $configurationService,
DatabaseConnection $databaseConnection = null)
public function __construct(CacheManager $cacheManager, ConfigurationService $configurationService)
{
$this->cacheManager = $cacheManager;
$this->configurationService = $configurationService;
$this->databaseConnection = $databaseConnection ?: $GLOBALS['TYPO3_DB'];
}

/**
Expand Down Expand Up @@ -179,16 +170,46 @@ protected function ensureCacheGroupsExist($groups)
*/
protected function forceFlushCoreFileAndDatabaseCaches()
{
// @deprecated Will be removed once TYPO3 7.6 support is removed
if (class_exists(ConnectionPool::class)) {
$this->_forceFlushCoreFileAndDatabaseCaches();
} else {
$this->_legacyForceFlushCoreFileAndDatabaseCaches();
}
}

/**
* Recursively delete cache directory and truncate all DB tables prefixed with 'cf_'
* @deprecated Will be removed once TYPO3 7.6 support is removed
*/
private function _legacyForceFlushCoreFileAndDatabaseCaches()
{
GeneralUtility::flushDirectory(PATH_site . 'typo3temp/Cache', true);
// Delete typo3temp/Cache
GeneralUtility::flushDirectory(PATH_site . 'typo3temp/var/Cache', true);
// Get all table names starting with 'cf_' and truncate them
$tables = $this->databaseConnection->admin_get_tables();
/** @var DatabaseConnection $db */
$db = $GLOBALS['TYPO3_DB'];
$tables = $db->admin_get_tables();
foreach ($tables as $table) {
$tableName = $table['Name'];
if (strpos($tableName, 'cf_') === 0) {
$this->databaseConnection->exec_TRUNCATEquery($tableName);
if ($tableName === 'cache_treelist' || strpos($tableName, 'cf_') === 0) {
$db->exec_TRUNCATEquery($tableName);
}
}
}

/**
* Recursively delete cache directory and truncate all DB tables prefixed with 'cf_'
*/
private function _forceFlushCoreFileAndDatabaseCaches()
{
// Delete typo3temp/Cache
GeneralUtility::flushDirectory(PATH_site . 'typo3temp/var/Cache', true);
// Get all table names from Default connection starting with 'cf_' and truncate them
$connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
$connection = $connectionPool->getConnectionByName('Default');
$tables = $connection->getSchemaManager()->listTables();
foreach ($tables as $table) {
if ($table->getName() === 'cache_treelist' || strpos($table->getName(), 'cf_') === 0) {
$connection->truncate($table->getName());
}
}
}
Expand Down