Skip to content

Commit

Permalink
Merge branch 'hotfix/fix_fallback_lng_seach' into 'release/2.3.0'
Browse files Browse the repository at this point in the history
Fix search in fallback language

See merge request metamodels/core!321
  • Loading branch information
zonky2 committed Aug 28, 2024
2 parents e45b58a + f26c9a3 commit eb3ff67
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Attribute/TranslatedReference.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,18 @@ public function unsetDataFor($arrIds)
*/
public function searchFor($strPattern)
{
return $this->searchForInLanguages($strPattern, [$this->getActiveLanguage()]);
// Search at active language and return findings.
if ([] !== ($items = $this->searchForInLanguages($strPattern, [$this->getActiveLanguage()]))) {
return $items;
}

// Search at fallback language as alternative and return findings.
if ($this->getActiveLanguage() !== $this->getFallbackLanguage()) {
return $this->searchForInLanguages($strPattern, [$this->getFallbackLanguage()]);

Check failure on line 287 in src/Attribute/TranslatedReference.php

View workflow job for this annotation

GitHub Actions / PHP: 8.1 Contao: ~4.13.0

ArgumentTypeCoercion: Argument 2 of MetaModels\Attribute\TranslatedReference::searchForInLanguages expects list<non-empty-string>, but parent type list{null|string} provided (reported by psalm)

Check failure on line 287 in src/Attribute/TranslatedReference.php

View workflow job for this annotation

GitHub Actions / PHP: 8.2 Contao: ~4.13.0

ArgumentTypeCoercion: Argument 2 of MetaModels\Attribute\TranslatedReference::searchForInLanguages expects list<non-empty-string>, but parent type list{null|string} provided (reported by psalm)

Check failure on line 287 in src/Attribute/TranslatedReference.php

View workflow job for this annotation

GitHub Actions / PHP: 8.3 Contao: ~4.13.0

ArgumentTypeCoercion: Argument 2 of MetaModels\Attribute\TranslatedReference::searchForInLanguages expects list<non-empty-string>, but parent type list{null|string} provided (reported by psalm)
}

// No finding in one language.
return [];
}

/**
Expand Down

0 comments on commit eb3ff67

Please sign in to comment.