8000 bug #47391 [LokaliseBridge] Fix push command --delete-missing options… · symfony/symfony@c2c522a · GitHub
[go: up one dir, main page]

Skip to content

Commit c2c522a

Browse files
committed
bug #47391 [LokaliseBridge] Fix push command --delete-missing options when there are no missing messages (rwionczek)
This PR was merged into the 5.4 branch. Discussion ---------- [LokaliseBridge] Fix push command --delete-missing options when there are no missing messages | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | | License | MIT | Doc PR | When `translation:push lokalise --delete-missing` command is executed and the messages are the same locally as in Lokalise, then the command removes all messages from Lokalise. This happens because the `getKeysIds` method in `LokaliseProvider` return all key ids when receives an empty array (empty `filter_keys` param in request to Lokalise API). This code prevent execution of `getKeysIds` method when there are no messages to delete from Lokalise. Commits ------- c4f651e [LokaliseBridge] Fix push command --delete-missing options when there are no missing messages
2 parents 6dadb96 + c4f651e commit c2c522a

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/Symfony/Component/Translation/Bridge/Lokalise/LokaliseProvider.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,12 @@ public function delete(TranslatorBagInterface $translatorBag): void
120120
$keysIds = [];
121121

122122
foreach ($catalogue->getDomains() as $domain) {
123-
$keysToDelete = [];
124-
foreach (array_keys($catalogue->all($domain)) as $key) {
125-
$keysToDelete[] = $key;
123+
$keysToDelete = array_keys($catalogue->all($domain));
124+
125+
if (!$keysToDelete) {
126+
continue;
126127
}
128+
127129
$keysIds += $this->getKeysIds($keysToDelete, $domain);
128130
}
129131

src/Symfony/Component/Translation/Bridge/Lokalise/Tests/LokaliseProviderTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,10 +699,12 @@ public function testDeleteProcess()
699699
$translatorBag->addCatalogue(new MessageCatalogue('en', [
700700
'messages' => ['a' => 'trans_en_a'],
701701
'validators' => ['post.num_comments' => '{count, plural, one {# comment} other {# comments}}'],
702+
'domain_without_missing_messages' => [],
702703
]));
703704
$translatorBag->addCatalogue(new MessageCatalogue('fr', [
704705
'messages' => ['a' => 'trans_fr_a'],
705706
'validators' => ['post.num_comments' => '{count, plural, one {# commentaire} other {# commentaires}}'],
707+
'domain_without_missing_messages' => [],
706708
]));
707709

708710
$provider = $this->createProvider(

0 commit comments

< 316A div class="h4 pr-2">Comments
 (0)
0