Problem/Motivation

Asking JSON:API's serializer for the schema of a field item list overwrites the values in that list. And saving the entity afterwards stores the sample values.

FieldNormalizer::getNormalizationSchema() needs one field item to describe, so it has this code:

$field_item = $object->appendItem($object->generateSampleItems());

FieldItemList::generateSampleItems() has no return value. It generates sample values and passes them to $this->setValue(), which replaces every value in the list.

appendItem(NULL) then adds an empty item, and only that item is removed afterwards. So the list ends up with the sample values, and the schema is built from an empty item, not a sample.

Issue fork drupal-3643170

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

dries created an issue. See original summary.

mukesh-kumar3 made their first commit to this issue’s fork.

mukesh-kumar3’s picture

Status: Active » Needs review
mukesh-kumar3’s picture

Nightwatch initially errored during logout in the setup hook for
machineNameTransliterationTest. The job passed on retry
without code changes.