diff --git a/core/lib/Drupal/Core/Database/Connection.php b/core/lib/Drupal/Core/Database/Connection.php index b088f66..a56bcf6 100644 --- a/core/lib/Drupal/Core/Database/Connection.php +++ b/core/lib/Drupal/Core/Database/Connection.php @@ -139,11 +139,11 @@ protected $prefixReplace = array(); /** - * List of un-prefixed table names, keyed by fully qualified table names. + * List of un-prefixed table names, keyed by prefixed table names. * * @var array */ - protected $prefixedTablesMap = []; + protected $unprefixedTablesMap = []; /** * Constructs a Connection object. @@ -302,7 +302,7 @@ protected function setPrefix($prefix) { // Set up a map of prefixed => un-prefixed tables. foreach ($this->prefixes as $table_name => $prefix) { if ($table_name !== 'default') { - $this->prefixedTablesMap[$prefix . $table_name] = $table_name; + $this->unprefixedTablesMap[$prefix . $table_name] = $table_name; } } } @@ -350,8 +350,8 @@ public function tablePrefix($table = 'default') { * An array of un-prefixed table names, keyed by their fully qualified table * names (i.e. prefix + table_name). */ - public function getPrefixedTablesMap() { - return $this->prefixedTablesMap; + public function getUnprefixedTablesMap() { + return $this->unprefixedTablesMap; } /** diff --git a/core/lib/Drupal/Core/Database/Schema.php b/core/lib/Drupal/Core/Database/Schema.php index cf8206f..8f2c758 100644 --- a/core/lib/Drupal/Core/Database/Schema.php +++ b/core/lib/Drupal/Core/Database/Schema.php @@ -192,7 +192,7 @@ public function findTables($table_expression) { $condition = $this->buildTableNameCondition('%', 'LIKE'); $condition->compile($this->connection, $this); - $individually_prefixed_tables = $this->connection->getPrefixedTablesMap(); + $individually_prefixed_tables = $this->connection->getUnprefixedTablesMap(); $default_prefix_length = strlen($this->connection->tablePrefix()); $tables = []; // Normally, we would heartily discourage the use of string @@ -200,7 +200,8 @@ public function findTables($table_expression) { // couldn't use db_select() here because it would prefix // information_schema.tables and the query would fail. // Don't use {} around information_schema.tables table. - foreach ($this->connection->query("SELECT table_name FROM information_schema.tables WHERE " . (string) $condition, $condition->arguments()) as $table) { + $results = $this->connection->query("SELECT table_name FROM information_schema.tables WHERE " . (string) $condition, $condition->arguments()); + foreach ($results as $table) { // Take into account tables that have an individual prefix. if (isset($individually_prefixed_tables[$table->table_name])) { $prefix_length = strlen($this->connection->tablePrefix($individually_prefixed_tables[$table->table_name]));