diff --git a/core/lib/Drupal/Core/Cache/DatabaseBackend.php b/core/lib/Drupal/Core/Cache/DatabaseBackend.php index 82606cd..57d86dd 100644 --- a/core/lib/Drupal/Core/Cache/DatabaseBackend.php +++ b/core/lib/Drupal/Core/Cache/DatabaseBackend.php @@ -351,7 +351,8 @@ protected function normalizeCid($cid) { * Defines the schema for the {cache_*} bin tables. */ public function getSchema($table_name) { - $schema[$this->bin] = array( + // {cache_*} bin tables all have same schema. + return array( 'description' => 'Storage for the cache API.', 'fields' => array( 'cid' => array( @@ -407,7 +408,6 @@ public function getSchema($table_name) { ), 'primary key' => array('cid'), ); - return isset($schema[$table_name]) ? $schema[$table_name] : FALSE; } } diff --git a/core/lib/Drupal/Core/Database/Connection.php b/core/lib/Drupal/Core/Database/Connection.php index e48e817..0d88069 100644 --- a/core/lib/Drupal/Core/Database/Connection.php +++ b/core/lib/Drupal/Core/Database/Connection.php @@ -627,19 +627,28 @@ protected function handleQueryException(\PDOException $e, $query, array $args = } /** - * Handle a missing table exception. + * Handles a missing table exception. * - * @param $e + * @param \PDOException $e + * The exception thrown by static::query(). * @param $query - * @param $args - * @param $options - * @return bool|StatementInterface + * The query executed by static::query(). + * @param array $args + * An array of arguments for the prepared statement. + * @param array $options + * An associative array of options to control how the query is run. + * + * @return \Drupal\Core\Database\StatementInterface|bool + * This method re-runs the query after creating the missing table. In this + * case it returns a \Drupal\Core\Database\StatementInterface object or + * FALSE if the schema provider is not specified in the $options. */ protected function handleMissingTable($e, $query, $args, $options) { + debug($options); if ($this->isTableMissingException($e) && $options['create_missing_table']) { if ($options['return'] == Database::RETURN_STATEMENT) { // This is a SELECT on a missing table. Creating the table and - // re-runing the query will result in an empty result so return that + // re-running the query will result in an empty result so return that // early instead. return new StatementEmpty(); } diff --git a/core/lib/Drupal/Core/Database/Query/Insert.php b/core/lib/Drupal/Core/Database/Query/Insert.php index 531e403..b9fa167 100644 --- a/core/lib/Drupal/Core/Database/Query/Insert.php +++ b/core/lib/Drupal/Core/Database/Query/Insert.php @@ -74,7 +74,8 @@ class Insert extends Query { public function __construct($connection, $table, array $options = array()) { $options += array( 'return' => Database::RETURN_INSERT_ID, - 'create_missing_table' => $table, + 'create_missing_table' => TRUE, + 'missing_table_name' => $table, ); parent::__construct($connection, $options); $this->table = $table; diff --git a/core/lib/Drupal/Core/Database/Query/Merge.php b/core/lib/Drupal/Core/Database/Query/Merge.php index 281d917..ff8bac8 100644 --- a/core/lib/Drupal/Core/Database/Query/Merge.php +++ b/core/lib/Drupal/Core/Database/Query/Merge.php @@ -136,7 +136,8 @@ class Merge extends Query implements ConditionInterface { public function __construct(Connection $connection, $table, array $options = array()) { $options['return'] = Database::RETURN_AFFECTED; if (!isset($options['create_missing_table'])) { - $options['create_missing_table'] = $table; + $options['create_missing_table'] = TRUE; + $options['missing_table_name'] = $table; } parent::__construct($connection, $options); $this->table = $table; diff --git a/core/lib/Drupal/Core/Database/SchemaProviderInterface.php b/core/lib/Drupal/Core/Database/SchemaProviderInterface.php index f11e4e4..0ae6b00 100644 --- a/core/lib/Drupal/Core/Database/SchemaProviderInterface.php +++ b/core/lib/Drupal/Core/Database/SchemaProviderInterface.php @@ -1,7 +1,8 @@