diff --git a/core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php b/core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php
index d989364..e755832 100644
--- a/core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php
+++ b/core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php
@@ -150,13 +150,12 @@ public function rename($key, $new_key) {
    */
   public function deleteMultiple(array $keys) {
     // Delete in chunks when a large array is passed.
-    do {
+    while ($keys) {
       $this->connection->delete($this->table)
         ->condition('name', array_splice($keys, 0, 1000))
         ->condition('collection', $this->collection)
         ->execute();
     }
-    while (count($keys));
   }
 
   /**
diff --git a/core/modules/system/src/Tests/KeyValueStore/StorageTestBase.php b/core/modules/system/src/Tests/KeyValueStore/StorageTestBase.php
index 3278173..b59828e 100644
--- a/core/modules/system/src/Tests/KeyValueStore/StorageTestBase.php
+++ b/core/modules/system/src/Tests/KeyValueStore/StorageTestBase.php
@@ -121,6 +121,8 @@ public function testCRUD() {
     $this->assertFalse($stores[0]->get('foo'));
     $this->assertFalse($stores[0]->get('bar'));
     $this->assertFalse($stores[0]->getMultiple(array('foo', 'bar')));
+    // Verify that deleting no items does not cause an error.
+    $stores[0]->deleteMultiple(array());
     // Verify that the item in the other collection still exists.
     $this->assertIdenticalObject($this->objects[5], $stores[1]->get('foo'));
 
