Problem/Motivation

I'm currently working on a new project and decided to use Drupal 10 for it as the release is just around the corner.
I'm using media with the media library, paragraphs, rabbit hole and some more modules.

I created a content type with media fields (using the media library) and some paragraphs.
Then I tried creating a node, but it didn't work.
The ajax request that is performed to add a new paragraph or to load the media library fails.

Looking at the logs, I have the following error: 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.

I debugged the issue and found out, that the problem is caused by rabbit hole.
Disabling the module fixed the issue.

I did some more debugging and found the cause of the error.
An instance of the PageRedirect class is present in the rabbit_hole form element.

To be more precise, I debugged Drupal\Core\KeyValueStore\DatabaseStorageExpirable::doSetWithExpire and found it in $value["rabbit_hole"]["redirect"]["rh_redirect"]["#element_validate"][0][0];
form debug

I tried to fix/verify that by adding the DependencySerializationTrait to the class.
This solved the issue for me.

Steps to reproduce

  1. Create a fresh install of drupal 10.0.0-rc1 with default settings
  2. Download the latest dev version of rabbit hole (dev-2.0.x 865b698)
  3. Install the media, media_library, rabbit_hole and rh_node modules
  4. Add a media field to the basic page content type (or any other content type)
  5. Use the media library as widget for the created media field
  6. Access the node add form of the content type
  7. Try to add a media item
  8. You should now see that the ajax request, which is supposed to load the media library fails

Proposed resolution

Add the Drupal\Core\DependencyInjection\DependencySerializationTrait trait to the Drupal\rabbit_hole\Plugin\RabbitHoleBehaviorPlugin\PageRedirect class.

I added a patch I made to solve the issue for me.

Remaining tasks

-

User interface changes

-

API changes

-

Data model changes

-

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

GRcwolf created an issue. See original summary.

grcwolf’s picture

Issue summary: View changes

Matroskeen made their first commit to this issue’s fork.

matroskeen’s picture

Status: Active » Needs review

Thanks for the report! I was able to reproduce the issue following those steps. Adding the trait seems to be the best option because the problem is in token service, which has a dependency on cache backend service, which usually has a database connection.

I think we can this trait to the base plugin class ensuring that we won't hit the same issue for other plugins. The MR is gonna be pretty straight-forward and will be merged as soon as we have green test results.

  • Matroskeen committed 514c143 on 2.0.x
    Issue #3323710 by Matroskeen, GRcwolf: Database serialization 
    

  • Matroskeen committed d72e73d on 8.x-1.x
    Issue #3323710 by Matroskeen, GRcwolf: Fixed database serialization in...
matroskeen’s picture

Status: Needs review » Fixed

Committed to 8.x-1.x and 2.0.x branches.
Thank you!

Status: Fixed » Closed (fixed)

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