Image fields trigger serialization error when editing profile directly

Created on 26 October 2023, 8 months ago

Problem/Motivation

Our profile type has an image field. When users create a profile, an image can be successfully uploaded to their profile with this image field. When the profile is saved, the image appears and is saved correctly.

However, if an admin edits the profile directly, removing the saved image or uploading a new image (if field was blank) triggers database serialization errors.

Other image fields throughout the site do not exhibit the same behaviour.

Steps to reproduce

Create a profile type with an image field set to 1 value.

Create a new user and create a new profile for this user, attaching an image via the image field.

Save the new profile.

Edit the new profile directly via a URL like /profile/XX/edit where XX is the profile ID.

Click the "remove" button for the image field. See AJAX error in console. Go to watchdog log and see new error logged:

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 2042 of /var/www/html/web/core/lib/Drupal/Core/Database/Connection.php).

Check other image fields on the website to see that removing/uploading images works as expected.

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇨🇦Canada endless_wander

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

Comments & Activities

  • Issue created by @endless_wander
  • 🇮🇳India dineshkumarbollu

    Hi @endless_wander

    I created new profile type with image field and add one user, after that in edit profile url(profile/1/edit) i am able to remove without any Ajax error in console and recent logs.

    Drupal version: 10

    attaching screen record link recording

  • 🇨🇦Canada endless_wander

    @dineshkumarbollu I am using Drupal 9 and will be upgrading to 10 in the coming weeks

    When I have time, I will test from scratch on D10 and slowly add the modules on my current site as there is likely an interaction causing the bug. On a hunch, I tried disabling all translation and internationalization modules, but the problem remains.

Production build 0.69.0 2024