Problem/Motivation

Exception thrown when previewing a comment on a block content entity with content translation enabled.

Steps to reproduce:

  1. Install the standard profile
  2. Install the content translation module
  3. Create a comment type and target entity is *block*
  4. Create a custom block-library with a comment field,
  5. Now create a simple block for the new existing block-type in a custom block library
  6. Place the block on a region e.g. side-bar-first,
  7. Now try to write something in a comment, click on *preview* showing in a blank page *The website encountered an unexpected error. Please try again later.*
  8. Once check the log it provides the Logic Exception, seems during this try to *serialize* the db connection object which is being prevented from __sleep

Proposed resolution

Prevent database from being serialised.

Remaining tasks

Write tests

User interface changes

None

API changes

None

Data model changes

None

Comments

roynilanjan created an issue. See original summary.

alexpott’s picture

Issue summary: View changes
StatusFileSize
new227 KB

@roynilanjan have you got an contrib or custom modules installed? If I follow the steps in the issue summary I can preview the comment just fine...

larowlan’s picture

Issue tags: +Needs tests
andypost’s picture

Confirm the failure, I got standard profile with content translation enabled

The website encountered an unexpected error. Please try again later.

LogicException: The database connection is not serializable. This probably means you are serializing an object that has an indirect reference to the database connection. Adjust your code so that is not necessary. Alternatively, look at DependencySerializationTrait as a temporary solution. in Drupal\Core\Database\Connection->__sleep() (line 1433 of core/lib/Drupal/Core/Database/Connection.php).

serialize(Array)
Drupal\Component\Serialization\PhpSerialize::encode(Array)
Drupal\Core\KeyValueStore\DatabaseStorageExpirable->setWithExpire('form-WRU2jWJrJfgNhZbfbdQpAlME4B2QzUHvp27AzhSelME', Array, 21600)
Drupal\Core\Form\FormCache->setCache('form-WRU2jWJrJfgNhZbfbdQpAlME4B2QzUHvp27AzhSelME', Array, Object)
Drupal\Core\Form\FormBuilder->setCache('form-WRU2jWJrJfgNhZbfbdQpAlME4B2QzUHvp27AzhSelME', Array, Object)
Drupal\Core\Form\FormBuilder->rebuildForm('comment_block_form', Object, Array)
Drupal\Core\Form\FormBuilder->processForm('comment_block_form', Array, Object)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object)
Drupal\Core\Entity\EntityFormBuilder->getForm(Object)
Drupal\comment\Controller\CommentController->getReplyForm(Object, Object, 'field_comments', NULL)
call_user_func_array(Array, Array)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1)
Stack\StackedHttpKernel->handle(Object, 1, 1)
Drupal\Core\DrupalKernel->handle(Object)

After posting comment and clicking "Reply" /comment/reply/block_content/1/field_comments/7
Preview is broken again

The website encountered an unexpected error. Please try again later.

LogicException: The database connection is not serializable. This probably means you are serializing an object that has an indirect reference to the database connection. Adjust your code so that is not necessary. Alternatively, look at DependencySerializationTrait as a temporary solution. in Drupal\Core\Database\Connection->__sleep() (line 1433 of core/lib/Drupal/Core/Database/Connection.php).

serialize(Array)
Drupal\Component\Serialization\PhpSerialize::encode(Array)
Drupal\Core\KeyValueStore\DatabaseStorageExpirable->setWithExpire('form-1tWHxhgSCho58XOsZpVW7AGmhtw0YbYANa4BDEhE05E', Array, 21600)
Drupal\Core\Form\FormCache->setCache('form-1tWHxhgSCho58XOsZpVW7AGmhtw0YbYANa4BDEhE05E', Array, Object)
Drupal\Core\Form\FormBuilder->setCache('form-1tWHxhgSCho58XOsZpVW7AGmhtw0YbYANa4BDEhE05E', Array, Object)
Drupal\Core\Form\FormBuilder->rebuildForm('comment_block_form', Object, Array)
Drupal\Core\Form\FormBuilder->processForm('comment_block_form', Array, Object)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object)
Drupal\Core\Entity\EntityFormBuilder->getForm(Object)
Drupal\comment\CommentLazyBuilders->renderForm('block_content', '1', 'field_comments', 'block')
call_user_func_array(Array, Array)
Drupal\Core\Render\Renderer->doRender(Array, 1)
Drupal\Core\Render\Renderer->render(Array, 1)
Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}()
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object)
Drupal\Core\Render\Renderer->renderPlain(Array)
Drupal\Core\Render\Renderer->renderPlaceholder('', Array)
Drupal\Core\Render\Renderer->replacePlaceholders(Array)
Drupal\Core\Render\Renderer->doRender(Array, 1)
Drupal\Core\Render\Renderer->render(Array, 1)
Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}()
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object)
Drupal\Core\Render\Renderer->renderRoot(Array)
Drupal\Core\Render\HtmlResponseAttachmentsProcessor->renderPlaceholders(Object)
Drupal\Core\Render\HtmlResponseAttachmentsProcessor->processAttachments(Object)
Drupal\Core\EventSubscriber\HtmlResponseSubscriber->onRespond(Object, 'kernel.response', Object)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.response', Object)
Symfony\Component\HttpKernel\HttpKernel->filterResponse(Object, Object, 1)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1)
Stack\StackedHttpKernel->handle(Object, 1, 1)
Drupal\Core\DrupalKernel->handle(Object)
roynilanjan’s picture

@alexpott: I haven't installed any contrib/custom module though... but happens when-ever serialization is prevented from __sleep()

dawehner’s picture

Status: Active » Needs review
StatusFileSize
new563 bytes

Let's see how much this breaks.

roynilanjan’s picture

Last patch seems a good idea to overcome exception handling from __sleep for now as far https://www.drupal.org/node/2463321#comment-9796361.

We need to test on that

alexpott’s picture

Priority: Normal » Major
Issue summary: View changes
Status: Needs review » Needs work
Issue tags: +D8MI

This feels at least a major bug and I guess considering I could not reproduce with about content translation that is it somehow related to that module.

tim.plunkett’s picture

Component: block.module » typed data system
swentel’s picture

I didn't even need to enable content translation/language at all to get the same error.

leisurman’s picture

I'm getting this error when uploading images that are using entity reference and the media library. Add the images do not get uploaded. If I disable the Interface Translation module the error goes away and the images can be uploaded. I tried the patch but it didn't work for me.

amateescu’s picture

Status: Needs work » Closed (cannot reproduce)
Issue tags: -database, -Needs tests, -D8MI

I tried the steps to reproduce from the issue summary, and I can't trigger the error anymore, even with Content Translation enabled.

Note that the problem mentioned in #11 has its own issue: #2905198: The database connection is not serializable

sylus’s picture

Version: 8.0.0 » 8.4.x-dev
Status: Closed (cannot reproduce) » Active

I am going to reopen this issue as am getting the exact same issue when trying to preview a comment and have a multilingual site configured with an additional french language.

On Drupal 8.3.x

I have already applied the patch over at: #2893029: EntityType objects cannot be reliably serialized without DependencySerializationTrait still to no avail. Additionally have tried the patch above.

Will try to look into this further and provide more information.

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

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

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

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev
quietone’s picture

Status: Active » Closed (cannot reproduce)
Issue tags: +Bug Smash Initiative

I tested this on 9.4.x and was not able to reproduce this error, that same as @amateescu 5 years ago. I followed the steps given in the Issue Summary. I then enabled translation on the custom block type and the comment type. Then when translating the comment, I did get a WSOD.

InvalidArgumentException: Invalid translation language (it) specified. in Drupal\Core\Entity\ContentEntityBase->addTranslation() (line 956 of /var/www/html/core/lib/Drupal/Core/Entity/ContentEntityBase.php).

That is a different error than the one here so I will make a new issue for that.

Therefore, closing this as cannot reproduce. If you are experiencing this problem on a supported version of Drupal reopen the issue, by setting the status to 'Active', and provide complete steps to reproduce the issue (starting from "Install Drupal core").

Thanks!

new issue is #3282397: Logic Exception with preview button for block-comment

johnv’s picture