Verified Commit 4e17b5f8 authored by Jess's avatar Jess
Browse files

Issue #3497647 by prudloff, xjm, quietone: StringDatabaseStorage::deleteStrings() does not work

(cherry picked from commit f1646309)
parent f82ca85c
Loading
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -526,7 +526,10 @@ protected function dbStringUpdate($string) {
  protected function dbDelete($table, $keys) {
    $query = $this->connection->delete($table, $this->options);
    foreach ($keys as $field => $value) {
      $query->condition($field, $value);
      if (!is_array($value)) {
        $value = [$value];
      }
      $query->condition($field, $value, 'IN');
    }
    return $query;
  }
+23 −0
Original line number Diff line number Diff line
@@ -242,4 +242,27 @@ protected function createTranslation(StringInterface $source, $langcode, array $
    ])->save();
  }

  /**
   * Tests that strings are correctly deleted.
   */
  public function testDeleteStrings(): void {
    $source = $this->storage->createString([
      'source' => 'Revision ID',
    ])->save();

    $this->storage->createTranslation([
      'lid' => $source->lid,
      'language' => 'fr',
      'translation' => 'Translated Revision ID',
    ])->save();

    // Confirm that the string has been created.
    $this->assertNotEmpty($this->storage->findString(['lid' => $source->lid]));

    $this->storage->deleteStrings(['lid' => $source->lid]);

    // Confirm that the string has been deleted.
    $this->assertEmpty($this->storage->findString(['lid' => $source->lid]));
  }

}