1. Site set as "Finnish" by default, English as another language
2. Created a store
3. Enabled translation support for the store at /admin/config/regional/content-language
4. Went to the store, store/1, click on translate tab to get to store/1/translations
5. I see that the original version of the store is in Finnish, I click on "Add" on the English row to add an English translation
6. I get following error

The website encountered an unexpected error. Please try again later.

Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException: The "commerce_store" entity type did not specify a "default" form class. in Drupal\Core\Entity\EntityTypeManager->getFormObject() (line 184 of core/lib/Drupal/Core/Entity/EntityTypeManager.php).
Drupal\Core\Entity\EntityManager->getFormObject('commerce_store', 'default') (Line: 44)
Drupal\Core\Entity\EntityFormBuilder->getForm(Object, 'default', Array) (Line: 348)
Drupal\content_translation\Controller\ContentTranslationController->add(Object, Object, Object, 'commerce_store')
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array) (Line: 144)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 64)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 652)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

I did also try to add a custom, translatable field for the store but I get the same error after that too. Above was with just the default fields of a store entity.

CommentFileSizeAuthor
#5 commerce_store_translation.patch662 bytestormu
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tormu created an issue. See original summary.

tormu’s picture

Issue summary: View changes
tormu’s picture

Version: 8.x-2.0-beta3 » 8.x-2.x-dev

Changed the version to 8.x-2.x-dev since switching to dev branch didn't offer any improvements on this.

bojanz’s picture

Side note, we need to add tests for translating all entity types, this regression happened in the past 6 months.

tormu’s picture

Posting the following on behalf of @tzveto, who is having problems with posting to d.o for some reason :(
Added the core patch that we made to be able to go past the crash..

After some research this is caused by getting the "Add" translation form with operation parameter
$operation = 'default';
and no 'default' operation is set which causes the error.

In the code in `Drupal\content_translation\Controller\ContentTranslationController.php` there is a TODO linking to https://www.drupal.org/node/2006348
and adding the following fixes the store translations

if ($entity_type_id == "commerce_store") {
  $operation = 'add';
}

Maybe this is not the proper way to fix this, because from a few other similar issues (missing form for a 'default' operation) with other modules this looks related to Drupal core entity system and I'm not aware with D8 to make changes there and if possible fix this on a more general level.
Any responds and suggestion for a better fix are appreciated.

  • bojanz committed 50818f1 on 8.x-2.x
    Issue #2827108 by tormu, bojanz: Crash when trying to translate a store
    
bojanz’s picture

Status: Active » Fixed

Pushed a fix, we'll add tests separately. Thank you for reporting!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.