Problem/Motivation

When a user saves a page they now receive this error

The website encountered an unexpected error. Please try again later.
TypeError: Illegal offset type in Drupal\Core\Entity\ContentEntityStorageBase->loadRevision() (line 639 of core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php).
Drupal\Core\Entity\ContentEntityStorageBase->loadRevision(Object) (Line: 59)
Drupal\content_moderation_notifications\NotificationInformation->getPreviousState(Object) (Line: 86)
Drupal\content_moderation_notifications\NotificationInformation->getTransition(Object) (Line: 107)
Drupal\content_moderation_notifications\NotificationInformation->getNotifications(Object) (Line: 90)
Drupal\content_moderation_notifications\Notification->processEntity(Object) (Line: 29)
content_moderation_notifications_entity_update(Object)
call_user_func_array('content_moderation_notifications_entity_update', Array) (Line: 403)
Drupal\Core\Extension\ModuleHandler->invokeAll('entity_update', Array) (Line: 251)
Drupal\Core\Entity\EntityStorageBase->invokeHook('update', Object) (Line: 897)
Drupal\Core\Entity\ContentEntityStorageBase->invokeHook('update', Object) (Line: 602)
Drupal\Core\Entity\EntityStorageBase->doPostSave(Object, 1) (Line: 782)
Drupal\Core\Entity\ContentEntityStorageBase->doPostSave(Object, 1) (Line: 527)
Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 802)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object) (Line: 339)
Drupal\Core\Entity\EntityBase->save() (Line: 270)
Drupal\node\NodeForm->save(Array, Object)
call_user_func_array(Array, Array) (Line: 114)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 52)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 592)
Drupal\Core\Form\FormBuilder->processForm('node_article_edit_form', Array, Object) (Line: 144)
Drupal\autosave_form\Form\AutosaveFormBuilder->processForm('node_article_edit_form', Array, Object) (Line: 320)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 97)
Drupal\autosave_form\Form\AutosaveFormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object) (Line: 39)
Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 564)
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: 158)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 42)
Drupal\force_password_change\Service\ForcePasswordChangeRedirectMiddleware->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: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 708)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

smustgrave created an issue. See original summary.

smustgrave’s picture

smustgrave’s picture

Status: Active » Needs review
jhedstrom’s picture

How does one reproduce this issue?

I think it also makes sense to move any logic change necessary into the

+++ b/src/NotificationInformation.php
@@ -56,9 +56,14 @@ class NotificationInformation implements NotificationInformationInterface {
+          $previous_state = $workflow->getTypePlugin()->getState($latest_entity->moderation_state->value);

I think $previous_state needs to be initialized as set to FALSE or the code below could cause undefined variable notices.

It might also be good to add a test that demonstrates the issue/fix if possible.

smustgrave’s picture

ON drupal 9.3.9
Have a workflow setup
Go into a node wtih the workflow attached
Click save and I get this error every time.

smustgrave’s picture

Following up on this one.

masterperoo’s picture

Bump

bkosborne’s picture

Status: Needs review » Closed (cannot reproduce)

The steps to reproduce in #5 are very simple but I cannot reproduce them. It's possible this was fixed elsewhere or there are more specifics about the setup that aren't known. But it's been a few years, I'm not sure smustgrave is still able to help with that?

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.