"The database connection is not serializable" error when trying to allow unlimited values

Created on 17 August 2024, 3 months ago
Updated 10 September 2024, 3 months ago

Problem/Motivation

When adding a new name field, if you try to allow unlimited values, a Drupal error status appears saying: "Oops, something went wrong. Check your browser's developer console for more details. ", in Firefox's console, I get this message:

Uncaught 
Object { message: "\nAn AJAX HTTP error occurred.\nHTTP Result Code: 500\nDebugging information follows.\nPath: /admin/structure/types/manage/dd_ct_profile_person/add-field/node/field_dd_field_aka_name?destinations%5B0%5D%5Broute_name%5D=entity.node.field_ui_fields&destinations%5B0%5D%5Broute_parameters%5D%5Bentity_type%5D=node&destinations%5B0%5D%5Broute_parameters%5D%5Bfield_name%5D=field_dd_field_aka_name&destinations%5B0%5D%5Broute_parameters%5D%5Bnode_type%5D=dd_ct_profile_person&destinations%5B1%5D=/admin/structure/types/manage/dd_ct_profile_person/fields/add-field\nStatusText: 500 Service unavailable (with message)\nResponseText: The website encountered an unexpected error. 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 1920 of core/lib/Drupal/Core/Database/Connection.php). serialize() (Line: 14)\nDrupal\\Component\\Serialization\\PhpSerialize::encode() (Line: 129)\nDrupal\\Core\\KeyValueStore\\DatabaseStorageExpirable->doSetWithExpire() (Line: 145)\nDrupal\\Core\\KeyValueStore\\DatabaseStorageExpirable->setWithExpire() (Line: 193)\nDrupal\\Core\\Form\\FormCache->setCache() (Line: 463)\nDrupal\\Core\\Form\\FormBuilder->setCache() (Line: 441)\nDrupal\\Core\\Form\\FormBuilder->rebuildForm() (Line: 633)\nDrupal\\Core\\Form\\FormBuilder->processForm() (Line: 326)\nDrupal\\Core\\Form\\FormBuilder->buildForm() (Line: 48)\nDrupal\\Core\\Entity\\EntityFormBuilder->getForm() (Line: 62)\nDrupal\\field_ui\\Controller\\FieldConfigAddController->fieldConfigAddConfigureForm()\ncall_user_func_array() (Line: 123)\nDrupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->Drupal\\Core\\EventSubscriber\\{closure}() (Line: 638)\nDrupal\\Core\\Render\\Renderer->executeInRenderContext() (Line: 121)\nDrupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)\nDrupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->Drupal\\Core\\EventSubscriber\\{closure}() (Line: 181)\nSymfony\\Component\\HttpKernel\\HttpKernel->handleRaw() (Line: 76)\nSymfony\\Component\\HttpKernel\\HttpKernel->handle() (Line: 53)\nDrupal\\Core\\StackMiddleware\\Session->handle() (Line: 48)\nDrupal\\Core\\StackMiddleware\\KernelPreHandle->handle() (Line: 28)\nDrupal\\Core\\StackMiddleware\\ContentLength->handle() (Line: 32)\nDrupal\\big_pipe\\StackMiddleware\\ContentLength->handle() (Line: 106)\nDrupal\\page_cache\\StackMiddleware\\PageCache->pass() (Line: 85)\nDrupal\\page_cache\\StackMiddleware\\PageCache->handle() (Line: 48)\nDrupal\\Core\\StackMiddleware\\ReverseProxyMiddleware->handle() (Line: 51)\nDrupal\\Core\\StackMiddleware\\NegotiationMiddleware->handle() (Line: 36)\nDrupal\\Core\\StackMiddleware\\AjaxPageState->handle() (Line: 51)\nDrupal\\Core\\StackMiddleware\\StackedHttpKernel->handle() (Line: 741)\nDrupal\\Core\\DrupalKernel->handle() (Line: 19)\n", name: "AjaxError", stack: "@http://127.0.0.1:52900/core/misc/ajax.js?v=10.3.2:196:32\n@http://127.0.0.1:52900/core/misc/ajax.js?v=10.3.2:1921:3\n" }
ajax.js:196:32
    error http://127.0.0.1:52900/core/misc/ajax.js?v=10.3.2:1219
    complete http://127.0.0.1:52900/core/misc/ajax.js?v=10.3.2:608
    jQuery 5

This occurs on both 8.x-1.0-rc6 and 8.x-1.x-dev versions of the module. Same message as far as I can tell.

Drupal is 10.3.2. PHP is 8.3.8. All running in a debian:bookworm-slim based Docker container.

Steps to reproduce

  • Have a mostly blank instance of Drupal 10.
  • Install the Name module.
  • Attempt to add a Name field to any content type while selecting "Unlimited" from the "Allowed number of values" field storage setting.

Proposed resolution

No idea.

Remaining tasks

No idea.

User interface changes

No idea.

API changes

No idea.

Data model changes

No idea.

πŸ› Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States jerrac

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024