Commit 622abdda authored by catch's avatar catch
Browse files

Issue #3416525 by smustgrave, cmlara, NikolaAt, alexpott: DatabaseStorage,...

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

(cherry picked from commit a5298099)
parent 0caccf51
Loading
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -105,6 +105,10 @@ public function read($name) {
   * {@inheritdoc}
   */
  public function readMultiple(array $names) {
    if (empty($names)) {
      return [];
    }

    $list = [];
    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();
+3 −0
Original line number Diff line number Diff line
@@ -44,6 +44,9 @@ public function testCRUD(): void {
    // Checking whether readMultiple() works with empty storage.
    $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.
    $data = $this->storage->read($name);
    $this->assertFalse($data);