EntityTranslationController::entityFormAlter will produce following warning when translations was enabled after entity creation:
Warning: Invalid argument supplied for foreach() in Drupal\translation_entity\EntityTranslationController->entityFormAlter() (line 244 of /var/www/drupal8/core/modules/translation_entity/lib/Drupal/translation_entity/EntityTranslationController.php).
Attached patch adds extra check for the $entity->translation array.
Comments
Comment #1
podarokThis should be covered by tests before commit
Comment #2
gábor hojtsyComment #3
jsbalseraRe-rolled the patch and add Tests
Comment #4
jsbalseraSorry, forgot to add the Test.
Comment #5
jsbalseraNow the complete patch.
Comment #6
alansaviolobo commentedreroll
Comment #9
rosinegrean commentedrerolled
Comment #22
quietone commented@InternetDevels, thank you for reporting this problem. We rely on issue reports like this to improve Drupal core.
I tested this on Drupal 9.5.x and did not get a warning when translations was enabled after entity creation.
Therefore, closing as outdated. If this is incorrect reopen the issue, by setting the status to 'Active', and add a comment explaining what still needs to be done.
Thanks!