I have website running in three different languages (EN,GB,DE). There is some issue with Single Content Export.

The Single Content Export only showing export configuration for content of EN website, although it lists all content when I type something in Content Entity text box. The moment I select any of the content from GB or DE site it stops updating export configuration tab and doesn’t show anything in it whether I am logged in as admin to EN site, GB site or DE site.

In my log I found

Initially when I first select the content of GB/DE site it throws

InvalidArgumentException: Invalid translation language (en) specified. in Drupal\Core\Entity\ContentEntityBase->getTranslation() (line 873 of /Applications/MAMP/htdocs/myproject/web/core/lib/Drupal/Core/Entity/ContentEntityBase.php).

And after first attempt it starts showing following error

Error: Call to a member function getTranslation() on null in Drupal\content_sync\Form\ContentSingleExportForm->updateExport() (line 177 of /Applications/MAMP/htdocs/myproject/web/modules/contrib/content_sync/src/Form/ContentSingleExportForm.php)

Comments

sanchitpuri created an issue. See original summary.

nicolas bouteille’s picture

I faced the same issue while testing the single item export.
This workaround allowed me to prevent the error from happening and see the generated YML content :

if ($entity->hasTranslation($language)) {
  $entity = $entity->getTranslation($language);
}
svetlio’s picture

Patch for #2. Thanks Nicolas.

blanca.esqueda’s picture

Version: 8.x-2.x-dev » 3.0.x-dev

Thank you for the catch!

Actually, the following lines are not necessary in the ContentSingleExportForm file:

$language = \Drupal::languageManager()->getCurrentLanguage()->getId();
$entity = $entity->getTranslation($language);

At some point, I was deciding if managing translations inside the same entity YML or as separate YML files, so I left it there when testing different options.

Code updated and included to 3.0.x-dev

blanca.esqueda’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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