Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 301015

Ensure that serializers injectable into Drupal\Core\KeyValueStore are aware of PHP objects

$
0
0

Problem/Motivation

The Drupal\Core\KeyValueStore\DatabaseStorage uses a configurable serializer to store PHP objects. This serializer is injected as a service in core. The pre-configured serializer used there Drupal\Component\Serialization\PhpSerialize. But this serializer could be swapped to any serializer that implements Drupal\Component\Serialization\SerializationInterface, for example:

  • Drupal\Component\Serialization\Yaml
  • Drupal\Component\Serialization\Json

These serializers will break PHP objects like in the form_state that gets saved in the key value store.

Proposed resolution

#839444: Make serializer customizable in Cache\MemoryBackend and Cache\DatabaseBackend will introduce a new interface Drupal\Component\Serialization\ObjectAwareSerializationInterface that just extends Drupal\Component\Serialization\SerializationInterface to clearly indicate that implementing Serializers are suitable for PHP Object serialization.

The Drupal\Core\KeyValueStore\DatabaseStorage and Drupal\Core\KeyValueStore\DatabaseStorageExpirable and their factories need to adjusted to expect a serializer that implements that new interface.

Remaining tasks

Write a patch.

User interface changes

None.

API changes

The Drupal\Core\KeyValueStore\DatabaseStorage and Drupal\Core\KeyValueStore\DatabaseStorageExpirable and their factories need to adjusted to expect a serializer that implements that new interface.

Data model changes

None.


Viewing all articles
Browse latest Browse all 301015

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>