diff --git a/core/modules/rest/src/Plugin/rest/resource/EntityResource.php b/core/modules/rest/src/Plugin/rest/resource/EntityResource.php index f4649e1..a66d5ab 100644 --- a/core/modules/rest/src/Plugin/rest/resource/EntityResource.php +++ b/core/modules/rest/src/Plugin/rest/resource/EntityResource.php @@ -198,18 +198,20 @@ public function post(EntityInterface $entity = NULL) { } /** - * Returns the casted value of a field item list. + * Gets the values from the field item list casted to the correct type. * - * Currently just primitive data knows how to cast itself to its actual value. - * Given that REST retrieves potential actual integers, but the DB stores - * strings, see https://www.drupal.org/node/2310089 we need to cast all values - * so we can compare properly that something changed. + * Values are casted to the correct type so we can determine whether or not + * something has changed. REST formats such as JSON support typed data but + * Drupal's database API will return values as strings. Currently, only + * primitive data types know how to cast their values to the correct type. * * @param \Drupal\Core\Field\FieldItemListInterface $field_item_list * The field item list to retrieve its data from. * * @return mixed[][] - * The casted value from the field item list. + * The values from the field item list casted to the correct type. The array + * of values returned is a multidimensional array keyed by delta and the + * property name. */ protected function getCastedValueFromFieldItemList(FieldItemListInterface $field_item_list) { $value = $field_item_list->getValue(); diff --git a/core/modules/serialization/config/install/serialization.settings.yml b/core/modules/serialization/config/install/serialization.settings.yml index 868a44f..aa3b693 100644 --- a/core/modules/serialization/config/install/serialization.settings.yml +++ b/core/modules/serialization/config/install/serialization.settings.yml @@ -5,5 +5,4 @@ link_domain: ~ # Before Drupal 8.3, typed data primitive values were normalized as strings, as # this was usually returned from database storage. A primitive data normalizer # has been introduced to get the casted value instead. -# @see https://www.drupal.org/node/2751325 bc_primitives_as_strings: false diff --git a/core/modules/serialization/serialization.install b/core/modules/serialization/serialization.install index fe6422f..e04ca01 100644 --- a/core/modules/serialization/serialization.install +++ b/core/modules/serialization/serialization.install @@ -39,5 +39,17 @@ function serialization_update_8301() { } /** + * Add serialization.settings::bc_primitives_as_strings configuration. + */ +function serialization_update_8302() { + $config_factory = \Drupal::configFactory(); + $config_factory->getEditable('serialization.settings') + ->set('bc_primitives_as_strings', FALSE) + ->save(FALSE); + + return t('The REST API will no longer output all values as strings. Integers/booleans will be used where appropriate. If your site depends on these value being strings, read the change record to learn how to enable the BC mode.'); +} + +/** * @} End of "defgroup updates-8.2.x-to-8.3.x". */