oroinc / platform

Main OroPlatform package with core functionality.
Other
627 stars 351 forks source link

Installation fails when migration scripts attempts to add translation data #1035

Open mrfroasty opened 4 years ago

mrfroasty commented 4 years ago

Summary
Upon adding translation, installation fails.

Steps to reproduce
Add data migration script that installs translation into the system. Sample code use: /** @var TranslationManager $translationManager */ $translationManager = $this->container->get('oro_translation.manager.translation'); $catalogue = $translator->getCatalogue($locale); foreach ($translations as $domain => $translates) { foreach ($translates as $key => $translate) { $translationManager->saveTranslation($key, $translate, $locale, $domain, Translation::SCOPE_INSTALLED); $catalogue->set($key, $translate, $domain); } }

Actual Result Installation fails with exception In Translation.php line 104: Argument 1 passed to Oro\Bundle\TranslationBundle\Entity\Translation::set La nguage() must be an instance of Oro\Bundle\TranslationBundle\Entity\Langu ag e, null given, called in /app/vendor/oro/platform/src/Oro/Bundle/Translat io nBundle/Manager/TranslationManager.php on line 81

Expected Result
If the feature is not supported, system should provide clear error messages. Details about your environment

mbessolov commented 4 years ago

@mrfroasty The problem is not related to installation or migrations. I do not see where you define $locale in your code example. It should be a valid language code.

mrfroasty commented 4 years ago

@mbessolov I think at the time the migration get executed, the installation has not installed the languages. But here is the original class that was tested and failed with the above error:

LoadProductUnitTranslation.txt