When using Inline Entity Form widget on a Moderated type I get.

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 /var/www/d8_scheduled_updates/core/lib/Drupal/Core/Database/Connection.php).

When click "Add new Entity" on the Inline Entity Form widget.

If I think the problem is in \Drupal\workbench_moderation\EntityTypeInfo::bundleFormAlter

// Submit handler to redirect to the
      $form['actions']['submit']['#submit'][] = [$this, 'bundleFormRedirect'];

The $this reference.

If that line is commented out you can add a new entity via the IEF widget(but of course the form isn't redirect)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tedbow created an issue. See original summary.

becw’s picture

Assigned: Unassigned » becw

  • becw committed 7ca9c0b on workbench_moderation-bug-2650388
    refs #2650388: fix issue where unserializable variables are stuffed into...
becw’s picture

Oh, this causes all kinds of issues. Any ajax on these forms is broken right now. Here's a patch!

Status: Needs review » Needs work

The last submitted patch, 4: workbench_moderation-bug-2650388-3.patch, failed testing.

The last submitted patch, 4: workbench_moderation-bug-2650388-3.patch, failed testing.

The last submitted patch, 4: workbench_moderation-bug-2650388-3.patch, failed testing.

  • becw committed e1a0b70 on workbench_moderation-bug-2650388
    refs #2650388: fix issue where unserializable services are stuffed into...
becw’s picture

becw’s picture

snufkin’s picture

From a functional standpoint this resolves a related issue for me, where the AJAX call to add paragraphs to a node would break with the following error:

Uncaught PHP Exception LogicException: "Settings can not be serialized. This probably means you are serializing an object that has an indirect reference to the Settings object. Adjust your code so that is not necessary." at docroot/core/lib/Drupal/Core/Site/Settings.php line 67

I don't want to change to RTBC since I can't judge whether or not the code is as it should be. But it does resolve the issue with paragraphs.

Crell’s picture

I think of the available options, #10 is the approach I hate the least. :-( Damn you FAPI!

phenaproxima’s picture

  1. +++ b/src/EntityTypeInfo.php
    @@ -289,7 +289,7 @@ class EntityTypeInfo {
    +      $form['actions']['submit']['#submit'][] = '\Drupal\workbench_moderation\EntityTypeInfo::bundleFormRedirect';
    

    I would suggest the use of get_class($this) rather than hardcoding the class name. Just for future proofing :)

  2. +++ b/src/EntityTypeInfo.php
    @@ -302,11 +302,12 @@ class EntityTypeInfo {
    +    $moderation_info = \Drupal::getContainer()->get('workbench_moderation.moderation_information');
    +    if ($moderation_info->hasForwardRevision($entity)) {
    

    Ideally this service should be injected.

Crell’s picture

Status: Needs review » Fixed

Committed #10. Thanks, Bec.

  • Crell committed 6dbb9ed on 8.x-1.x authored by becw
    Issue #2650388 by becw: Using Inline Entity Form widget on Moderated...

Status: Fixed » Closed (fixed)

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