Problem/Motivation
Drupal throws a fatal error when trying to add a translation to entity which already has a translation on given language.
Original report:
This error occurred when adding an English translation of a German article (node/2/translations/add/de/en
):
InvalidArgumentException: Invalid translation language (en) specified. in Drupal\Core\Entity\ContentEntityBase->addTranslation() (line 691 of core\lib\Drupal\Core\Entity\ContentEntityBase.php).
Steps to reproduce
- Install using standard profile in English
- Log in as a user with "translate any entity" permission - user 1 will do
- Create an English article node
- Install Content Translation module
- Add German language
- Enable content translation for article nodes with the default settings
- Go to de/node/1/translations/add/en/de and add a translation
- Go back to de/node/1/translations/add/en/de
- You will get a fatal error
or
- Go to content admin and use the filters to find the node I want to translate. Click its Translation operation link.
- Add a French translation and save it. This takes me back to the content admin page.
- Wait, I forgot to change something! But I can't see my node any more as it's not in the first page of results. I know, I'll just press Back and that'll get me back to the form I was just at, right?
- BOOM.
Note there may be other ways to reproduce this such as unchecking Create new revision
in the node and translation.
Proposed resolution
Redirect to the translation overview page.
Remaining tasks
Create patch with testDecide on where to send the user- Review
- Commit