summaryrefslogtreecommitdiffstatshomepage
path: root/core/modules
diff options
context:
space:
mode:
authorxjm <xjm@65776.no-reply.drupal.org>2025-06-15 13:20:29 -0500
committerxjm <xjm@65776.no-reply.drupal.org>2025-06-15 13:20:29 -0500
commitf1646309b7a907b23935449f7dc98bc11b1f2aef (patch)
tree83e967aadd971a8326de3048429ef09cf90c8fee /core/modules
parent71103ea36ab1290021741fd4f0df52250adb73dd (diff)
downloaddrupal-11.x.tar.gz
drupal-11.x.zip
Issue #3497647 by prudloff, xjm, quietone: StringDatabaseStorage::deleteStrings() does not workHEAD11.x
Diffstat (limited to 'core/modules')
-rw-r--r--core/modules/locale/src/StringDatabaseStorage.php5
-rw-r--r--core/modules/locale/tests/src/Kernel/LocaleStringTest.php23
2 files changed, 27 insertions, 1 deletions
diff --git a/core/modules/locale/src/StringDatabaseStorage.php b/core/modules/locale/src/StringDatabaseStorage.php
index f023d1968ae7..75c73411978d 100644
--- a/core/modules/locale/src/StringDatabaseStorage.php
+++ b/core/modules/locale/src/StringDatabaseStorage.php
@@ -527,7 +527,10 @@ class StringDatabaseStorage implements StringStorageInterface {
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;
}
diff --git a/core/modules/locale/tests/src/Kernel/LocaleStringTest.php b/core/modules/locale/tests/src/Kernel/LocaleStringTest.php
index f5f27b01a627..b007c7ab55b0 100644
--- a/core/modules/locale/tests/src/Kernel/LocaleStringTest.php
+++ b/core/modules/locale/tests/src/Kernel/LocaleStringTest.php
@@ -258,4 +258,27 @@ class LocaleStringTest extends KernelTestBase {
])->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]));
+ }
+
}