Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 295807

LogicException: The database connection is not serializable. [META]

$
0
0

Problem/Motivation

Creating this issue to unite many other issues, that are reported by contrib modules, in order to get a precise description of the problem.

Several contrib modules report problem when hitting an AJAX button. The expected action is not performed, instead nothing happens, or the following message appears:

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()

Apparently, the Ajax buttons makes the page being cached, before the action is executed and the (presumably) cached page is re-established with new data.

Steps to reproduce

Test prerequisites:
- enable the 'locale' module (User interface translation), which also requires Language module
- enable a contrib (field) module
- on /admin/config/regional/language/add, add another non-English language (having both English and your favorite one)
- (optional) on admin/config/regional/language/detection , enable both 'Url' and 'user' , having 'Url' first
- (optional) on admin/structure/block , add the 'Language switcher' for easy switch
- create a content type TYPE, add a contrib field

Test preparation:
- in any language, create a node of above type, save the form;
Test execution 1 - no error expected:
- in default (English) language, create a node of above type (page /node/8/edit), save;
- in default (English) language, edit the node of above type, press the Ajax [Add more] button;
- expected result: the expected action is performed

Test execution 2 - error encountered:
- change the language of the user (in user data or via
- in the alternative language, create a node of above type (page /node/8/edit), save;
- in the alternative language, edit the node of above type, press the widget's Ajax button ('Add more', 'Delete', or any other text);
- expected result: the expected action is performed
- actual result: the above-mentioned error message is logged/displayed.

Proposed resolution

Find a solution which not bothers contrib code.

Remaining tasks

- propose solutions above
- add related issues to this issue
- define if the 'forms system' is the correct core Component.
- Propose a better message that clearly states

LogicException: [...] Alternatively, add use DependencySerializationTrait; to the proper object as a temporary solution. [...]

User interface changes

None to be expected.

API changes

None to be expected.

Data model changes

None to be expected.

Release notes snippet

pressumabley something like:
'When using use StringTranslationTrait; in contrib modules, the additionally added use DependencySerializationTrait; is now redundant/obsolete.'


Viewing all articles
Browse latest Browse all 295807

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>