This was marked fixed, but we still get an exception being thrown. I have a node that is not set to be translatable, which gets 'zxx" as a language when it is created (through a migration process). This causes an exception being thrown inside EntityOperations::updateOrCreateFromEntity at the point when the translation is being added to the $content_moderation_state entity.

if ($entity->getEntityType()->hasKey('langcode')) {
      $entity_langcode = $entity->language()->getId();
      if (!$content_moderation_state->hasTranslation($entity_langcode)) {
        $content_moderation_state->addTranslation($entity_langcode);
      }
      if ($content_moderation_state->language()->getId() !== $entity_langcode) {
        $content_moderation_state = $content_moderation_state->getTranslation($entity_langcode);
      }
    }

Debugging this, I see that the $content_moderation_state entity has its language set to 'en' (site default), which is why the $content_moderation_state->hasTranslation($entity_langcode) fails ($entity_langcode='zxx').

Should we add extra checks here? or is the problem more that the $content_moderation_state doens't have it's language code set to 'zxx' (like the non-translated entity) ??

Comments

kriboogh created an issue. See original summary.

kriboogh’s picture

Status: Active » Needs review
StatusFileSize
new670 bytes
kriboogh’s picture

Status: Needs review » Needs work

The last submitted patch, 2: core-content_moderation-2856917-2.patch, failed testing.

timmillwood’s picture

sam152’s picture

What version was this fixed in? I noticed this was logged against 8.3.x.

timmillwood’s picture

Status: Needs work » Postponed (maintainer needs more info)

Is this still an issue?

tacituseu’s picture

kriboogh’s picture

Not sure if it is still an issue, we have put content moderation usage on hold until it will be considered stable.

amateescu’s picture

Title: Moderating a non-translatable entity type throws exception (part 2) » Moderating an entity that uses a special language (e.g. LANGCODE_NOT_SPECIFIED) throws exception
Version: 8.3.0-beta1 » 8.4.x-dev
Status: Postponed (maintainer needs more info) » Needs review
Issue tags: -Needs tests
StatusFileSize
new1.74 KB
new2.52 KB

I just hit this today while working on a test for Content Moderation, so yes, it's still very much an issue :)

The last submitted patch, 10: 2856917-test-only.patch, failed testing. View results

timmillwood’s picture

Status: Needs review » Reviewed & tested by the community

Nice @amateescu!

Very simple patch and test coverage. Looks like @kriboogh had the right fix, just took a test to prove it.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 10: 2856917-10.patch, failed testing. View results

amateescu’s picture

Status: Needs work » Reviewed & tested by the community

That seemed to be a random fail.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

  • xjm committed f589b88 on 8.5.x
    Issue #2856917 by amateescu, kriboogh: Moderating an entity that uses a...

  • xjm committed 39349a6 on 8.4.x
    Issue #2856917 by amateescu, kriboogh: Moderating an entity that uses a...
xjm’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.5.x and 8.4.x. Thanks!

xjm’s picture

Version: 8.5.x-dev » 8.4.x-dev

(Since it's a straight up non-disruptive bugfix.)

Status: Fixed » Closed (fixed)

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