diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 1900afc..d883a2d 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -439,7 +439,7 @@ function install_begin_request(&$install_state) { // Ensure that the active configuration directory is empty before installation // starts. if ($install_state['config_verified'] && empty($task)) { - $config = Database::getConnection()->schema()->tableExists('config');; + $config = Database::getConnection()->schema()->tableExists('config'); if (!empty($config)) { $task = NULL; throw new AlreadyInstalledException($container->get('string_translation')); diff --git a/core/lib/Drupal/Core/Config/DatabaseStorage.php b/core/lib/Drupal/Core/Config/DatabaseStorage.php index b7673f3..0d4796f 100644 --- a/core/lib/Drupal/Core/Config/DatabaseStorage.php +++ b/core/lib/Drupal/Core/Config/DatabaseStorage.php @@ -46,6 +46,7 @@ class DatabaseStorage implements StorageInterface { * A database table name to store configuration data in. * @param array $options * (optional) Any additional database connection options to use in queries. + * For testing, set 'no_table_creation' to TRUE to prevent table creation. */ public function __construct(Connection $connection, $table, array $options = array()) { $this->connection = $connection; @@ -90,6 +91,9 @@ public function read($name) { } } catch (\Exception $e) { + if (!empty($this->options['no_table_creation'])) { + throw $e; + } } return $data; } @@ -110,6 +114,9 @@ public function readMultiple(array $names) { } } catch (\Exception $e) { + if (!empty($this->options['no_table_creation'])) { + throw $e; + } } return $list; } @@ -164,7 +171,7 @@ protected function doWrite($name, $data) { */ protected function ensureTableExists() { try { - if (!$this->connection->schema()->tableExists($this->table)) { + if (!$this->connection->schema()->tableExists($this->table) && empty($this->options['no_table_creation'])) { $this->connection->schema()->createTable($this->table, static::schemaDefinition()); return TRUE; } @@ -268,6 +275,9 @@ public function listAll($prefix = '') { ), $this->options)->fetchCol(); } catch (\Exception $e) { + if (!empty($this->options['no_table_creation'])) { + throw $e; + } return array(); } } diff --git a/core/modules/config/lib/Drupal/config/Tests/Storage/DatabaseStorageTest.php b/core/modules/config/lib/Drupal/config/Tests/Storage/DatabaseStorageTest.php index 516bb9d..213ad3a 100644 --- a/core/modules/config/lib/Drupal/config/Tests/Storage/DatabaseStorageTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/Storage/DatabaseStorageTest.php @@ -2,7 +2,7 @@ /** * @file - * Definition of Drupal\config\Tests\Storage\DatabaseStorageTest. + * Contains \Drupal\config\Tests\Storage\DatabaseStorageTest. */ namespace Drupal\config\Tests\Storage; @@ -24,30 +24,8 @@ public static function getInfo() { function setUp() { parent::setUp(); - $schema['config'] = array( - 'description' => 'Database storage for the configuration system.', - 'fields' => array( - 'name' => array( - 'description' => 'The identifier for the configuration entry, such as module.example (the name of the file, minus the file extension).', - 'type' => 'varchar', - 'length' => 255, - 'not null' => TRUE, - 'default' => '', - ), - 'data' => array( - 'description' => 'The raw data for this configuration entry.', - 'type' => 'blob', - 'not null' => TRUE, - 'size' => 'big', - 'translatable' => TRUE, - ), - ), - 'primary key' => array('name'), - ); - db_create_table('config', $schema['config']); - $this->storage = new DatabaseStorage($this->container->get('database'), 'config'); - $this->invalidStorage = new DatabaseStorage($this->container->get('database'), 'invalid'); + $this->invalidStorage = new DatabaseStorage($this->container->get('database'), 'invalid', array('no_table_creation' => TRUE)); // ::listAll() verifications require other configuration data to exist. $this->storage->write('system.performance', array()); diff --git a/core/modules/config/lib/Drupal/config/Tests/Storage/FileStorageTest.php b/core/modules/config/lib/Drupal/config/Tests/Storage/FileStorageTest.php index d430bd3..bcd49989 100644 --- a/core/modules/config/lib/Drupal/config/Tests/Storage/FileStorageTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/Storage/FileStorageTest.php @@ -29,6 +29,7 @@ function setUp() { // FileStorage::listAll() requires other configuration data to exist. $this->storage->write('system.performance', \Drupal::config('system.performance')->get()); + $this->storage->write('core.extension', array('module' => array())); } protected function read($name) {