While importing the content with paragraph fields I came across the error:

Drupal\Core\Entity\EntityStorageException: Placeholders must have a trailing [] if they are to be expanded with an array of values. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 783 of /var/www/html/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

The error occurs either on importing a new paragraph (to replicate: create the content -> export -> delete the content -> import) or importing the paragraphs over existing ones.

The error is connected to 'behavior_settings' field which stores its values in a database as a serialized array. Unserialization happens in Drupal core - Drupal\serialization\Normalizer\PrimitiveDataNormalizer->normalize() explicitly unserialized such fields. Without the patch, it tries to save the array instead of a serialized string. The patch forces it to serialize the value before importing.

Comments

klimp created an issue. See original summary.

klimp’s picture

Title: Paragraph's field 'behavior_settings' causes an error while importing a new paragraph » Paragraph's field 'behavior_settings' causes an error while importing paragraphs. Importing serialized fields
klimp’s picture

Issue summary: View changes
klimp’s picture

StatusFileSize
new1.96 KB

A better implementation. Now every entity being exported is getting processed by a method checking if there any fields to be serialized.

klimp’s picture

Status: Needs work » Needs review
klimp’s picture

Issue summary: View changes
asterovim’s picture

The patch content_sync-paragraph_behavior_settings-4-D8.patch work's perfectly. Thanks you.

blanca.esqueda’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, @klimp!
The patch will be added to 8.x-2.x-dev

  • Blanca.Esqueda committed e96d0fe on 8.x-2.x authored by klimp
    Issue #3037199 by klimp: Paragraph's field 'behavior_settings' causes an...
blanca.esqueda’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.