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];

I tried to fix/verify that by adding the DependencySerializationTrait to the class.
This solved the issue for me.
Steps to reproduce
- Create a fresh install of drupal 10.0.0-rc1 with default settings
- Download the latest dev version of rabbit hole (dev-2.0.x 865b698)
- Install the media, media_library, rabbit_hole and rh_node modules
- Add a media field to the basic page content type (or any other content type)
- Use the media library as widget for the created media field
- Access the node add form of the content type
- Try to add a media item
- 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
-
| Comment | File | Size | Author |
|---|
Issue fork rabbit_hole-3323710
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
Comment #2
grcwolfComment #5
matroskeenThanks 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
tokenservice, 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.
Comment #8
matroskeenCommitted to 8.x-1.x and 2.0.x branches.
Thank you!