platform icon indicating copy to clipboard operation
platform copied to clipboard

Installation fails when migration scripts attempts to add translation data

Open mrfroasty opened this issue 4 years ago • 2 comments

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

  • OroPlatform version: x.y.z
  • PHP version: 7.3.18
  • Database (PostgreSQL) version 9.6 Additional information
    I did eventually move it out of migration into a command, but I thought the above handling might improve other developers experience. By the way the above was a discussion in slack orocommerce channel.

mrfroasty avatar Aug 19 '20 05:08 mrfroasty

@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.

mbessolov avatar Aug 19 '20 07:08 mbessolov

@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

mrfroasty avatar Aug 19 '20 19:08 mrfroasty