[#2137815] InvalidArgumentException: Invalid translation language specified.
Merge request reports
Activity
added 1 commit
- 8386d74a - 2137815: fix Invalid translation language specified
added 152 commits
-
8386d74a...b0243326 - 150 commits from branch
project:11.x
- 79cc0d8f - Update 4 files
- b561f9dc - 2137815: fix Invalid translation language specified
-
8386d74a...b0243326 - 150 commits from branch
397 397 /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ 398 398 $entity = $route_match->getParameter($entity_type_id); 399 399 400 // If the entity already has the target translation, redirect to the 401 // translation overview page. 402 if ($entity->hasTranslation($target->getId())) { 403 return $this->redirect("entity.$entity_type_id.content_translation_overview", [$entity_type_id => $entity->id()]); 404 } - Comment on lines +400 to +404
Is this the correct behaviour? The original request for this behaviour mentioned at least adding a message telling the user what had happened. But I don't understand the rationale for going to the translation overview page instead of the edit page for the translation which is surely closer to the user intended.
120 120 $this->assertSession()->responseContains('<span class="translation-entity-all-languages">(all languages)</span>'); 121 121 } 122 122 123 // Asserts that once a translation exists the user is redirected to the 124 // translations overview page. 125 if ($entity_type_id === 'entity_test_mul_changed') { 126 $this->drupalGet($add_url); 127 $this->assertSession()->statusCodeEquals(200); 128 $this->assertSession()->pageTextContains('Translations'); 129 $this->assertStringContainsString('/entity_test_mul_changed/manage/1/translations', $this->getUrl()); 130 // Ensure the redirect works also for user 1. 131 $this->drupalLogin($this->rootUser); 132 $this->drupalGet($add_url); 133 $this->assertSession()->statusCodeEquals(200); 134 $this->assertSession()->pageTextContains('Translations'); 135 $this->assertStringContainsString('/entity_test_mul_changed/manage/1/translations', $this->getUrl()); - Comment on lines +130 to +135
366 366 $title = $this->entityFormTitle($entity); 367 367 // When editing the original values display just the entity label. 368 368 if ($is_translation) { 369 $t_args = ['%language' => $languages[$form_langcode]->getName(), '%title' => $entity->label(), '@title' => $title]; 369 $t_args = ['%language' => $languages[$form_langcode]->getName(), '%title' => $entity->label() ?? $entity->id(), '@title' => $title]; - Comment on lines -369 to +369
These changes to use entity ID instead of the label when the label is null feel out-of-scope. I guess that they are caused by testing with an entity with no title. I think we should add a title to that entity instead of doing this fix like this. I think we should handle NULL labels in a different and fuller way. Making these changes here will result in a piecemeal approach.
51 51 */ 52 52 protected function entityFormTitle(EntityInterface $entity) { 53 53 $type_name = node_get_type_label($entity); 54 return t('<em>Edit @type</em> @title', ['@type' => $type_name, '@title' => $entity->label()]); 54 return t('<em>Edit @type</em> @title', ['@type' => $type_name, '@title' => $entity->label() ?? $entity->id()]); changed this line in version 4 of the diff
71 71 'bypass node access', 72 72 'administer nodes', 73 73 'translate any entity', 74 'create content translations', 117 117 * Returns an array of permissions needed for the translator. 118 118 */ 119 119 protected function getTranslatorPermissions() { 120 return array_filter([$this->getTranslatePermission(), 'create content translations', 'update content translations', 'delete content translations']); 120 return array_filter([$this->getTranslatePermission(), 'create content translations', 'update content translations', 'delete content translations', 'translate any entity']); added 2470 commits
-
b561f9dc...7dacab44 - 2468 commits from branch
project:11.x
- 70abbe10 - Update 4 files
- bbf4f33c - 2137815: fix Invalid translation language specified
-
b561f9dc...7dacab44 - 2468 commits from branch