Issue #3416525 by smustgrave, cmlara, NikolaAt, alexpott: DatabaseStorage, readMultiple throws error when receive empty array

merge-requests/8936/merge
catch 2024-08-10 09:41:08 +09:00
parent b8aa161ca0
commit a52980995a
2 changed files with 7 additions and 0 deletions

View File

@ -105,6 +105,10 @@ class DatabaseStorage implements StorageInterface {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function readMultiple(array $names) { public function readMultiple(array $names) {
if (empty($names)) {
return [];
}
$list = []; $list = [];
try { try {
$list = $this->connection->query('SELECT [name], [data] FROM {' . $this->connection->escapeTable($this->table) . '} WHERE [collection] = :collection AND [name] IN ( :names[] )', [':collection' => $this->collection, ':names[]' => $names], $this->options)->fetchAllKeyed(); $list = $this->connection->query('SELECT [name], [data] FROM {' . $this->connection->escapeTable($this->table) . '} WHERE [collection] = :collection AND [name] IN ( :names[] )', [':collection' => $this->collection, ':names[]' => $names], $this->options)->fetchAllKeyed();

View File

@ -44,6 +44,9 @@ abstract class ConfigStorageTestBase extends KernelTestBase {
// Checking whether readMultiple() works with empty storage. // Checking whether readMultiple() works with empty storage.
$this->assertEmpty($this->storage->readMultiple([$name])); $this->assertEmpty($this->storage->readMultiple([$name]));
// readMultiple() accepts an empty array.
$this->assertSame([], $this->storage->readMultiple([]), 'Empty query should return empty array');
// Reading a non-existing name returns FALSE. // Reading a non-existing name returns FALSE.
$data = $this->storage->read($name); $data = $this->storage->read($name);
$this->assertFalse($data); $this->assertFalse($data);