Open web-fu opened 1 year ago
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.
Have a look at https://github.com/lexik/LexikTranslationBundle/issues/388#issuecomment-1260756831, it solved our issue
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:
{{ 'I am a text to transalte'|trans }}
/translations
endpoint provided by the libraryThe 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"
@web-fu thanks for the clear reproduction steps.
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.