You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to refresh the cache via console and I received this error:
Argument 3 passed to Symfony\Bundle\FrameworkBundle\Translation\Translator::addResource() must be of the type string, null given, called in vendor/lexik/translation-bundle/Translation/Translator.php on line 44
After many attempts and some debug, I discovered the problem is caused by this query:
public function getAllDomainsByLocale()
{
return $this->createQueryBuilder('tu')
->select('te.locale, tu.domain')
->leftJoin('tu.translations', 'te')
->addGroupBy('te.locale')
->addGroupBy('tu.domain')
->getQuery()
->getArrayResult();
}
If the locale column contains any null value the error is triggered.
I don't know if the problem is the leftJoin (maybe should be a normal join) or addResource signature (maybe should accept also null values).
For now I removed the invalid translation_unit rows that caused the problem.
The text was updated successfully, but these errors were encountered:
Same error.
I am implementing project on SF 6.2, previously it was iplemented on SF3.4. Database for translations was just copied from one project to another.
As I said, I solved the issue deleting orphan entry from lexik_trans_unit, but I'm not sure it is a "real" solution or just a workaround.
I'll explain how the bug can occur, so maybe it's more clear:
Prepare your view, with your trans term ready ex: {{ 'I am a text to transalte'|trans }}
Go to the /translations endpoint provided by the library
Check for missing translations, but don't translate them
Refresh the cache -> BUG
The missing translation is saved and became an orphan lexik_trans_unit without locale and because Symfony\Bundle\FrameworkBundle\Translation\Translator::addResource() expect a string (and not a null), it crashes.
The question is: the code shoud exclude orphans or not?
I think "missing translation" should not be an "halting error", just think to a deploy CI that crasches because some translation is missing.
If I would to avoid that an untraslated text to arrive in production:
1 . There should be an explicit option "CI_FAIL_IF_TRANSLATION_MISSING"
2. There should be an Exception, not a type error.
I was trying to refresh the cache via console and I received this error:
Argument 3 passed to Symfony\Bundle\FrameworkBundle\Translation\Translator::addResource() must be of the type string, null given, called in vendor/lexik/translation-bundle/Translation/Translator.php on line 44
After many attempts and some debug, I discovered the problem is caused by this query:
If the
locale
column contains anynull
value the error is triggered.I don't know if the problem is the leftJoin (maybe should be a normal join) or addResource signature (maybe should accept also null values).
For now I removed the invalid translation_unit rows that caused the problem.
The text was updated successfully, but these errors were encountered: