Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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 CreditAttribution: alansaviolobo commentedreroll
Comment #9
rosinegrean CreditAttribution: rosinegrean commentedrerolled
Comment #22
quietone CreditAttribution: quietone at PreviousNext 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!