diff --git a/core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php b/core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php index 369490b..7b14fcb 100644 --- a/core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php +++ b/core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php @@ -186,23 +186,19 @@ public function fetchCounter($name) { */ public function incrementCounter($name) { try { - $this->connection->merge($this->table) - ->expression('value', 'value + 1') - ->keys([ - 'collection' => $this->collection, - 'name' => $name, - ]) - ->execute(); - } - catch (\Exception $e) { - // If no value exists, initialize the counter. - $this->connection->insert($this->table) + $this->connection + ->insert($this->table) ->fields([ 'collection' => $this->collection, 'name' => $name, 'value' => 1, ]) ->execute(); + } catch (\Exception $e) { + $this->connection->update($this->table) + ->expression('value', 'value + 1') + ->condition('name', $name) + ->execute(); } }