diff --git a/typo3/sysext/core/Classes/Cache/Cache.php b/typo3/sysext/core/Classes/Cache/Cache.php index 8198f21e3734ee235ec52d936a52cb39d9da1cba..c8f314e6ce8b9ad58e92b0ab44849286faf6f902 100644 --- a/typo3/sysext/core/Classes/Cache/Cache.php +++ b/typo3/sysext/core/Classes/Cache/Cache.php @@ -98,18 +98,4 @@ class Cache { return $tableDefinitions; } - /** - * A slot method to inject the required caching framework database tables to the - * tables defintions string - * - * @param array $sqlString - * @param string $extensionKey - * @return array - */ - public function addCachingFrameworkRequiredDatabaseSchemaToTablesDefintion(array $sqlString, $extensionKey) { - $GLOBALS['typo3CacheManager']->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']); - $sqlString[] = static::getDatabaseTableDefinitions(); - return array('sqlString' => $sqlString, 'extensionKey' => $extensionKey); - } - } diff --git a/typo3/sysext/core/Classes/Category/CategoryRegistry.php b/typo3/sysext/core/Classes/Category/CategoryRegistry.php index a77e25cba58a475e1dcc3543e1d155bf56a1b5af..1cd14075d717ec090d5885a7b76c9934ca8b46a4 100644 --- a/typo3/sysext/core/Classes/Category/CategoryRegistry.php +++ b/typo3/sysext/core/Classes/Category/CategoryRegistry.php @@ -88,8 +88,8 @@ class CategoryRegistry implements \TYPO3\CMS\Core\SingletonInterface { throw new \InvalidArgumentException('TYPO3\\CMS\\Core\\Category\\CategoryRegistry No tableName given.', 1369122038); } - // Makes sure nothing was registered yet. - if (!$this->isRegistered($tableName, $fieldName)) { + // Makes sure there is an existing table configuration and nothing registered yet: + if (isset($GLOBALS['TCA'][$tableName]) && !$this->isRegistered($tableName, $fieldName)) { $this->registry[$extensionKey][$tableName][$fieldName] = $options; $result = TRUE; } @@ -372,29 +372,4 @@ class CategoryRegistry implements \TYPO3\CMS\Core\SingletonInterface { \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns($tableName, $columns); } } - - /** - * A slot method to inject the required category database fields to the - * tables defintion string - * - * @param array $sqlString - * @return array - */ - public function addCategoryDatabaseSchemaToTablesDefintion(array $sqlString) { - $sqlString[] = $this->getDatabaseTableDefinitions(); - return array('sqlString' => $sqlString); - } - - /** - * A slot method to inject the required category database fields of an - * extension to the tables defintion string - * - * @param array $sqlString - * @param string $extensionKey - * @return array - */ - public function addExtensionCategoryDatabaseSchemaToTablesDefintion(array $sqlString, $extensionKey) { - $sqlString[] = $this->getDatabaseTableDefinition($extensionKey); - return array('sqlString' => $sqlString, 'extensionKey' => $extensionKey); - } } diff --git a/typo3/sysext/core/Tests/Unit/Category/CategoryRegistryTest.php b/typo3/sysext/core/Tests/Unit/Category/CategoryRegistryTest.php index 371af3915d87934b522be36ccdafa61f07793513..e4017d778d8eb2a772a685a121a208e9110490a9 100644 --- a/typo3/sysext/core/Tests/Unit/Category/CategoryRegistryTest.php +++ b/typo3/sysext/core/Tests/Unit/Category/CategoryRegistryTest.php @@ -77,6 +77,13 @@ class CategoryRegistryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase { $this->assertTrue($this->fixture->add('test_extension_a', $this->tables['first'], 'categories')); } + /** + * @test + */ + public function doesAddReturnFalseOnUndefinedTable() { + $this->assertFalse($this->fixture->add('test_extension_a', 'undefined_table', 'categories')); + } + /** * @test * @expectedException \InvalidArgumentException diff --git a/typo3/sysext/extensionmanager/Classes/Utility/InstallUtility.php b/typo3/sysext/extensionmanager/Classes/Utility/InstallUtility.php index 432ddad5c081ef9e02fc64354cae850c29c13da5..bbe5a7a8fc128c9eea8d8d327df405aac6107d39 100644 --- a/typo3/sysext/extensionmanager/Classes/Utility/InstallUtility.php +++ b/typo3/sysext/extensionmanager/Classes/Utility/InstallUtility.php @@ -123,7 +123,7 @@ class InstallUtility implements \TYPO3\CMS\Core\SingletonInterface { $this->loadExtension($extensionKey); } $this->reloadCaches(); - $this->processRuntimeDatabaseUpdates($extensionKey); + $this->processCachingFrameworkUpdates(); $this->saveDefaultConfiguration($extension['key']); } @@ -240,40 +240,20 @@ class InstallUtility implements \TYPO3\CMS\Core\SingletonInterface { } /** - * Gets all database updates due to runtime configuration, like caching framework or - * category api for example + * Gets all registered caches and creates required caching framework tables. * - * @param string $extensionKey + * @return void */ - protected function processRuntimeDatabaseUpdates($extensionKey) { - $sqlString = $this->emitTablesDefinitionIsBeingBuiltSignal($extensionKey); - if (!empty($sqlString)) { - $this->updateDbWithExtTablesSql(implode(LF . LF . LF . LF, $sqlString)); - } - } + protected function processCachingFrameworkUpdates() { + $extTablesSqlContent = ''; - /** - * Emits a signal to manipulate the tables definitions - * - * @param string $extensionKey - * @return mixed - * @throws \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException - */ - protected function emitTablesDefinitionIsBeingBuiltSignal($extensionKey) { - $signalReturn = $this->signalSlotDispatcher->dispatch(__CLASS__, 'tablesDefinitionIsBeingBuilt', array('sqlString' => array(), 'extensionKey' => $extensionKey)); - $sqlString = $signalReturn['sqlString']; - if (!is_array($sqlString)) { - throw new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException( - sprintf( - 'The signal %s of class %s returned a value of type %s, but array was expected.', - 'tablesDefinitionIsBeingBuilt', - __CLASS__, - gettype($sqlString) - ), - 1382360258 - ); + // @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(); + + if ($extTablesSqlContent !== '') { + $this->updateDbWithExtTablesSql($extTablesSqlContent); } - return $sqlString; } /** @@ -283,7 +263,7 @@ class InstallUtility implements \TYPO3\CMS\Core\SingletonInterface { */ public function reloadCaches() { \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::removeCacheFiles(); - \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->reloadTypo3LoadedExtAndClassLoaderAndExtLocalconf()->loadExtensionTables(); + \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->reloadTypo3LoadedExtAndClassLoaderAndExtLocalconf(); } /** diff --git a/typo3/sysext/extensionmanager/Tests/Unit/Utility/InstallUtilityTest.php b/typo3/sysext/extensionmanager/Tests/Unit/Utility/InstallUtilityTest.php index 3724bf2b530bdf841da57ec4cb5e7ba303c1a1d3..d3621232cab5df5a1e328d2b0e3f0fc20ba66bbf 100644 --- a/typo3/sysext/extensionmanager/Tests/Unit/Utility/InstallUtilityTest.php +++ b/typo3/sysext/extensionmanager/Tests/Unit/Utility/InstallUtilityTest.php @@ -64,7 +64,6 @@ class InstallUtilityTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase { 'loadExtension', 'unloadExtension', 'processDatabaseUpdates', - 'processRuntimeDatabaseUpdates', 'reloadCaches', 'processCachingFrameworkUpdates', 'saveDefaultConfiguration', @@ -120,10 +119,20 @@ class InstallUtilityTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase { /** * @test */ - public function installCallsProcessRuntimeDatabaseUpdates() { + public function installCallsProcessDatabaseUpdates() { $this->installMock->expects($this->once()) - ->method('processRuntimeDatabaseUpdates') - ->with($this->extensionKey); + ->method('processDatabaseUpdates') + ->with($this->extensionData); + + $this->installMock->install($this->extensionKey); + } + + /** + * @test + */ + public function installCallsProcessCachingFrameworkUpdates() { + $this->installMock->expects($this->once()) + ->method('processCachingFrameworkUpdates'); $this->installMock->install($this->extensionKey); } diff --git a/typo3/sysext/extensionmanager/ext_localconf.php b/typo3/sysext/extensionmanager/ext_localconf.php index ff21ce1817469590bd5a7287ed49131870f500aa..f339e043940b98cad13717d3db303b782e2c087c 100644 --- a/typo3/sysext/extensionmanager/ext_localconf.php +++ b/typo3/sysext/extensionmanager/ext_localconf.php @@ -21,17 +21,5 @@ if (TYPO3_MODE === 'BE') { 'TYPO3\\CMS\\Core\\Package\\PackageManager', 'scanAvailablePackages' ); - $signalSlotDispatcher->connect( - 'TYPO3\\CMS\\Extensionmanager\\Utility\\InstallUtility', - 'tablesDefinitionIsBeingBuilt', - 'TYPO3\\CMS\\Core\\Cache\\Cache', - 'addCachingFrameworkRequiredDatabaseSchemaToTablesDefintion' - ); - $signalSlotDispatcher->connect( - 'TYPO3\\CMS\\Extensionmanager\\Utility\\InstallUtility', - 'tablesDefinitionIsBeingBuilt', - 'TYPO3\\CMS\\Core\\Category\\CategoryRegistry', - 'addExtensionCategoryDatabaseSchemaToTablesDefintion' - ); } } diff --git a/typo3/sysext/install/Classes/Controller/Action/Tool/UpdateWizard.php b/typo3/sysext/install/Classes/Controller/Action/Tool/UpdateWizard.php index 94a9743f6a2ed21d8cc5f30a8c483921c328c2f7..c5287a2667454e9723b415c338379f4e4d4334aa 100644 --- a/typo3/sysext/install/Classes/Controller/Action/Tool/UpdateWizard.php +++ b/typo3/sysext/install/Classes/Controller/Action/Tool/UpdateWizard.php @@ -258,9 +258,9 @@ class UpdateWizard extends Action\AbstractAction implements Action\ActionInterfa /** @var $sqlHandler \TYPO3\CMS\Install\Service\SqlSchemaMigrationService */ $sqlHandler = $this->objectManager->get('TYPO3\\CMS\\Install\\Service\\SqlSchemaMigrationService'); - /** @var \TYPO3\CMS\Install\Service\CachingFrameworkDatabaseSchemaService $cachingFrameworkDatabaseSchemaService */ - $cachingFrameworkDatabaseSchemaService = $this->objectManager->get('TYPO3\\CMS\\Install\\Service\\CachingFrameworkDatabaseSchemaService'); - $expectedSchemaString = $cachingFrameworkDatabaseSchemaService->getCachingFrameworkRequiredDatabaseSchema(); + /** @var \TYPO3\CMS\Install\Service\SqlExpectedSchemaService $expectedSchemaService */ + $expectedSchemaService = $this->objectManager->get('TYPO3\\CMS\\Install\\Service\\SqlExpectedSchemaService'); + $expectedSchemaString = $expectedSchemaService->getCachingFrameworkRequiredDatabaseSchema(); $cleanedExpectedSchemaString = implode(LF, $sqlHandler->getStatementArray($expectedSchemaString, TRUE, '^CREATE TABLE ')); $neededTableDefinition = $sqlHandler->getFieldDefinitions_fileContent($cleanedExpectedSchemaString); $currentTableDefinition = $sqlHandler->getFieldDefinitions_database(); diff --git a/typo3/sysext/install/Classes/Service/CachingFrameworkDatabaseSchemaService.php b/typo3/sysext/install/Classes/Service/CachingFrameworkDatabaseSchemaService.php deleted file mode 100644 index 84d5e321fc95f577accdc6214278b24f3e6f4b27..0000000000000000000000000000000000000000 --- a/typo3/sysext/install/Classes/Service/CachingFrameworkDatabaseSchemaService.php +++ /dev/null @@ -1,84 +0,0 @@ -<?php -namespace TYPO3\CMS\Install\Service; - -/*************************************************************** - * Copyright notice - * - * (c) 2013 Thomas Maroschik - * All rights reserved - * - * This script is part of the TYPO3 project. The TYPO3 project is - * free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * The GNU General Public License can be found at - * http://www.gnu.org/copyleft/gpl.html. - * A copy is found in the textfile GPL.txt and important notices to the license - * from the author is found in LICENSE.txt distributed with these scripts. - * - * - * This script is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * This copyright notice MUST APPEAR in all copies of the script! - ***************************************************************/ - -/** - * This service provides the sql schema for the caching framework - */ -class CachingFrameworkDatabaseSchemaService { - - /** - * 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(); - $extbaseObjectFakeName = uniqid('extbase_object'); - $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$extbaseObjectFakeName] = array(); - $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_reflection'] = array(); - $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_typo3dbbackend_tablecolumns'] = array(); - /** @var \TYPO3\CMS\Core\Cache\CacheManager $cacheManager */ - $cacheManager = $GLOBALS['typo3CacheManager']; - $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; - } - - /** - * A slot method to inject the required caching framework database tables to the - * tables defintions string - * - * @param array $sqlString - * @return array - */ - public function addCachingFrameworkRequiredDatabaseSchemaToTablesDefintion(array $sqlString) { - $sqlString[] = $this->getCachingFrameworkRequiredDatabaseSchema(); - return array('sqlString' => $sqlString); - } - -} diff --git a/typo3/sysext/install/Classes/Service/Exception/UnexpectedSignalReturnValueTypeException.php b/typo3/sysext/install/Classes/Service/Exception/UnexpectedSignalReturnValueTypeException.php deleted file mode 100644 index b6ea001338482cc0197b21828e06b5e702c10d08..0000000000000000000000000000000000000000 --- a/typo3/sysext/install/Classes/Service/Exception/UnexpectedSignalReturnValueTypeException.php +++ /dev/null @@ -1,32 +0,0 @@ -<?php -namespace TYPO3\CMS\Install\Service\Exception; - -/*************************************************************** - * Copyright notice - * - * (c) 2013 Christian Kuhn <lolli@schwarzbu.ch> - * All rights reserved - * - * This script is part of the TYPO3 project. The TYPO3 project is - * free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * The GNU General Public License can be found at - * http://www.gnu.org/copyleft/gpl.html. - * - * This script is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * This copyright notice MUST APPEAR in all copies of the script! - ***************************************************************/ - -/** - * An exception thrown if the return value type of a signal is not the expected one. - */ -class UnexpectedSignalReturnValueTypeException extends CoreVersionServiceException { - -} \ No newline at end of file diff --git a/typo3/sysext/install/Classes/Service/SqlExpectedSchemaService.php b/typo3/sysext/install/Classes/Service/SqlExpectedSchemaService.php index 5cdee625dc651c0b9065864f654156b0af900598..253e83f1b3aa9a9201c8f2e83ea979e3a9998a1b 100644 --- a/typo3/sysext/install/Classes/Service/SqlExpectedSchemaService.php +++ b/typo3/sysext/install/Classes/Service/SqlExpectedSchemaService.php @@ -42,12 +42,6 @@ class SqlExpectedSchemaService { */ protected $objectManager = NULL; - /** - * @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher - * @inject - */ - protected $signalSlotDispatcher; - /** * Get expected schema array * @@ -87,31 +81,50 @@ class SqlExpectedSchemaService { } } - $sqlString = $this->emitTablesDefinitionIsBeingBuiltSignal($sqlString); + // Add caching framework sql definition + $sqlString[] = $this->getCachingFrameworkRequiredDatabaseSchema(); + + // Add category registry sql definition + $sqlString[] = \TYPO3\CMS\Core\Category\CategoryRegistry::getInstance()->getDatabaseTableDefinitions(); return implode(LF . LF . LF . LF, $sqlString); } /** - * Emits a signal to manipulate the tables definitions + * Get schema SQL of required cache framework tables. + * + * This method needs ext_localconf and ext_tables loaded! * - * @param array $sqlString - * @return mixed + * 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: This construct needs to be improved. It does not recognise if some custom ext overwrote the extbase cache config + * @TODO: Solve this as soon as cache configuration is separated from ext_localconf / ext_tables + * @TODO: It might be possible to reduce this ugly construct by circumventing the 'singleton' of CacheManager by using 'new' + * + * @return string Cache framework SQL */ - protected function emitTablesDefinitionIsBeingBuiltSignal(array $sqlString) { - $signalReturn = $this->signalSlotDispatcher->dispatch(__CLASS__, 'tablesDefinitionIsBeingBuilt', array('sqlString' => $sqlString)); - $sqlString = $signalReturn['sqlString']; - if (!is_array($sqlString)) { - throw new Exception\UnexpectedSignalReturnValueTypeException( - sprintf( - 'The signal %s of class %s returned a value of type %s, but array was expected.', - 'tablesDefinitionIsBeingBuilt', - __CLASS__, - gettype($sqlString) - ), - 1382351456 - ); - } + public function getCachingFrameworkRequiredDatabaseSchema() { + $cacheConfigurationBackup = $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']; + $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_datamapfactory_datamap'] = array(); + $extbaseObjectFakeName = uniqid('extbase_object'); + $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$extbaseObjectFakeName] = array(); + $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_reflection'] = array(); + $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_typo3dbbackend_tablecolumns'] = array(); + /** @var \TYPO3\CMS\Core\Cache\CacheManager $cacheManager */ + $cacheManager = $GLOBALS['typo3CacheManager']; + $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; } } diff --git a/typo3/sysext/install/ext_localconf.php b/typo3/sysext/install/ext_localconf.php index 52a8f5f8d7257a1bde6f1ffaa4e3bfb81998a17e..06007b404227a84e69210f0566c969f0686b52b8 100644 --- a/typo3/sysext/install/ext_localconf.php +++ b/typo3/sysext/install/ext_localconf.php @@ -52,17 +52,3 @@ $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['sysext_file_ // Version 4.7: Migrate the flexforms of MediaElement $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['mediaElementFlexform'] = 'TYPO3\\CMS\\Install\\Updates\\MediaFlexformUpdate'; - -$signalSlotDispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher'); -$signalSlotDispatcher->connect( - 'TYPO3\\CMS\\Install\\Service\\SqlExpectedSchemaService', - 'tablesDefinitionIsBeingBuilt', - 'TYPO3\\CMS\\Install\\Service\\CachingFrameworkDatabaseSchemaService', - 'addCachingFrameworkRequiredDatabaseSchemaToTablesDefintion' -); -$signalSlotDispatcher->connect( - 'TYPO3\\CMS\\Install\\Service\\SqlExpectedSchemaService', - 'tablesDefinitionIsBeingBuilt', - 'TYPO3\\CMS\\Core\\Category\\CategoryRegistry', - 'addCategoryDatabaseSchemaToTablesDefintion' -);