Loading core/modules/locale/src/StringDatabaseStorage.php +4 −1 Original line number Diff line number Diff line Loading @@ -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; } Loading core/modules/locale/tests/src/Kernel/LocaleStringTest.php +23 −0 Original line number Diff line number Diff line Loading @@ -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])); } } Loading
core/modules/locale/src/StringDatabaseStorage.php +4 −1 Original line number Diff line number Diff line Loading @@ -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; } Loading
core/modules/locale/tests/src/Kernel/LocaleStringTest.php +23 −0 Original line number Diff line number Diff line Loading @@ -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])); } }