Error Encountered on User Entity Edit Form Using AJAX

Created on 21 May 2025, 18 days ago

Problem/Motivation

I encountered the following error on the user entity edit form when interacting with a field that has AJAX interactions, such as adding another item:

Uncaught
Object { message: "\nAn AJAX HTTP error occurred.\nHTTP Result Code: 500\nDebugging information follows.\nPath: /user/56590/edit?ajax_form=1\nStatusText: error\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(Array) (Line: 14)\nDrupal\\Component\\Serialization\\PhpSerialize::encode(Array) (Line: 111)\nDrupal\\Core\\KeyValueStore\\DatabaseStorageExpirable->doSetWithExpire('form-bC8nPj7GVUYIUKmzkimLh15pzItcBw2l5jwlkqQJMpM', Array, 21600) (Line: 127)\nDrupal\\Core\\KeyValueStore\\DatabaseStorageExpirable->setWithExpire('form-bC8nPj7GVUYIUKmzkimLh15pzItcBw2l5jwlkqQJMpM', Array, 21600) (Line: 193)\nDrupal\\Core\\Form\\FormCache->setCache('form-bC8nPj7GVUYIUKmzkimLh15pzItcBw2l5jwlkqQJMpM', Array, Object) (Line: 463)\nDrupal\\Core\\Form\\FormBuilder->setCache('form-bC8nPj7GVUYIUKmzkimLh15pzItcBw2l5jwlkqQJMpM', Array, Object) (Line: 441)\nDrupal\\Core\\Form\\FormBuilder->rebuildForm('user_form', Object, Array) (Line: 633)\nDrupal\\Core\\Form\\FormBuilder->processForm('user_form', Array, Object) (Line: 325)\nDrupal\\Core\\Form\\FormBuilder->buildForm(Object, Object) (Line: 73)\nDrupal\\Core\\Controller\\FormController->getContentResult(Object, Object)\ncall_user_func_array(Array, Array) (Line: 123)\nDrupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->Drupal\\Core\\EventSubscriber\\{closure}() (Line: 627)\nDrupal\\Core\\Render\\Renderer->executeInRenderContext(Object, Object) (Line: 121)\nDrupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)\nDrupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->Drupal\\Core\\EventSubscriber\\{closure}() (Line: 181)\nSymfony\\Component\\HttpKernel\\HttpKernel->handleRaw(Object, 1) (Line: 76)\nSymfony\\Component\\HttpKernel\\HttpKernel->handle(Object, 1, 1) (Line: 68)\nDrupal\\simple_oauth\\HttpMiddleware\\BasicAuthSwap->handle(Object, 1, 1) (Line: 58)\nDrupal\\Core\\StackMiddleware\\Session->handle(Object, 1, 1) (Line: 48)\nDrupal\\Core\\StackMiddleware\\KernelPreHandle->handle(Object, 1, 1) (Line: 28)\nDrupal\\Core\\StackMiddleware\\ContentLength->handle(Object, 1, 1) (Line: 106)\nDrupal\\page_cache\\StackMiddleware\\PageCache->pass(Object, 1, 1) (Line: 85)\nDrupal\\page_cache\\StackMiddleware\\PageCache->handle(Object, 1, 1) (Line: 48)\nDrupal\\Core\\StackMiddleware\\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)\nDrupal\\Core\\StackMiddleware\\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)\nDrupal\\Core\\StackMiddleware\\AjaxPageState->handle(Object, 1, 1) (Line: 51)\nDrupal\\Core\\StackMiddleware\\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)\nDrupal\\Core\\DrupalKernel->handle(Object) (Line: 19)\n", name: "AjaxError", stack: "@https://l2-rails.ddev.site/core/misc/ajax.js?v=10.2.12:196:32\n@https://l2-rails.ddev.site/core/misc/ajax.js?v=10.2.12:1916:3\n" }

Steps to reproduce

  1. Update the user via the entity edit form
  2. Try to add another item to a field uses AJAX.
πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States droath

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