InvalidArgumentException: Field moderation_state is unknown

Created on 2 July 2024, 11 months ago

Problem/Motivation

The website encountered an unexpected error. Try again later.

InvalidArgumentException: Field moderation_state is unknown. in Drupal\Core\Entity\ContentEntityBase->getTranslatedField() (line 616 of core/lib/Drupal/Core/Entity/ContentEntityBase.php).
Drupal\Core\Entity\ContentEntityBase->get() (Line: 163)
Drupal\moderation_state_condition\Plugin\Condition\ModerationState->evaluate() (Line: 76)
Drupal\Core\Condition\ConditionManager->execute() (Line: 85)
Drupal\Core\Condition\ConditionPluginBase->execute() (Line: 26)
Drupal\block\BlockAccessControlHandler->resolveConditions() (Line: 116)
Drupal\block\BlockAccessControlHandler->checkAccess() (Line: 109)
Drupal\Core\Entity\EntityAccessControlHandler->access() (Line: 329)
Drupal\Core\Entity\EntityBase->access() (Line: 63)
Drupal\block\BlockRepository->getVisibleBlocksPerRegion() (Line: 138)
Drupal\block\Plugin\DisplayVariant\BlockPageVariant->build() (Line: 270)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare() (Line: 128)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse() (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray()
call_user_func() (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 186)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 741)
Drupal\Core\DrupalKernel->handle() (Line: 19)

Steps to reproduce

  1. Enable this module (and its dependencies),
  2. apply the default "Editorial" content moderation workflow for the default "Basic block" content block type,
  3. create a dummy content block and place it somewhere with the Moderation state condition
  4. add a node of the default "Article" type,
  5. the error appears on save and every page visit.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇮🇹Italy kopeboy Milan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @kopeboy
  • Assigned to nickdjm
  • Status changed to Postponed: needs info 9 months ago
  • 🇨🇦Canada nickdjm

    I can't seem to reproduce the error you're seeing following the steps provided.

    I made a fresh install, enabled the module, enabled the workflow on content blocks (which I will comment on shortly), added it to the block layout and created an article. All works as expected. No errors seen.

    Is there something I'm missing?

    Also, it is worth noting that enabling the workflow on the block itself will basically do nothing as far as moderation_state_condition is concerned. This module currently only supports nodes. If you enable your workflow on the article and then place a block to conditionally show on a specific workflow state you should see the results you (hopefully) want. When I have some time I'll add other entity support, but until then it's only nodes.

  • Status changed to Closed: works as designed 5 days ago
  • 🇨🇦Canada nickdjm

    Closing as outdated and no further action is needed.

Production build 0.71.5 2024