Content moderation does not sanity check original entity moderate state is present / exists

Created on 9 June 2022, over 2 years ago
Updated 30 September 2023, about 1 year ago

Problem/Motivation

Recently we had some issues with Behat and @afterscenarios cleaning up afterwards. It was possible for an original entity to come to exist without an original moderation state and this would throw errors in the after scenario.

A simple solution was add some sanity checks to ModerationInformation that simply checks if $original_entity->moderation_state is even set / is NULL.

Steps to reproduce

Uncertain, but we'll write some unit tests if we can for the matter.

Here are some of the errors we saw in Behat if it helps anyone:

Attempt to read property "moderation_state" on null
/core/modules/content_moderation/src/ModerationInformation.php:223

Proposed resolution

Add some basic sanity checks for the presence of a moderation state on an original entity.

Remaining tasks

-Unit tests will be necessary to demonstrate possibility, and will capture a simple solution.

πŸ› Bug report
Status

Needs work

Version

10.1 ✨

Component
Content moderationΒ  β†’

Last updated 24 days ago

  • Maintained by
  • πŸ‡¦πŸ‡ΊAustralia @Sam152
Created by

πŸ‡ΊπŸ‡ΈUnited States jnicola

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¬πŸ‡·Greece bserem

    This is affecting Drupal 10.1 too. Patch doesn't seem to fix things, so I'll set it back to needs work.

    
    Error message
    
        Warning: Attempt to read property "value" on null in Drupal\content_moderation\ModeratedNodeListBuilder->buildRow() (line 115 of core/modules/content_moderation/src/ModeratedNodeListBuilder.php).
    
        Drupal\content_moderation\ModeratedNodeListBuilder->buildRow(Object) (Line: 242)
        Drupal\Core\Entity\EntityListBuilder->render() (Line: 128)
        Drupal\content_moderation\ModeratedNodeListBuilder->render() (Line: 23)
        Drupal\content_moderation\Controller\ModeratedContentController->nodeListing()
        call_user_func_array(Array, Array) (Line: 123)
        Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 592)
        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}() (Line: 182)
        Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
        Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
        Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
        Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
        Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
        Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 50)
        Drupal\ban\BanMiddleware->handle(Object, 1, 1) (Line: 48)
        Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
        Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 51)
        Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
        Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
    
  • last update about 1 year ago
    29,672 pass
Production build 0.71.5 2024