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\YamlDrupal\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 for 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.
Comments
Comment #15
wim leers#839444: Make serializer customizable for Cache\DatabaseBackend landed!
Comment #16
andypostAs of form state, it probably needs some prefix for cache keys to make serialization swappable
Comment #17
mkalkbrennerThe igbinary nodule can read existing cache entries created by the php serializer to allow a transition to igbinary. But it doesn't work the other way.
Maybe a clearing all caches in case the igbinary module gets uninstalled is the better way compared to a prefix.
This should also happen when you move your site to a system where igbinary is not available.
Comment #18
andypostThe KV store is not a cache, caches are fixed already
Comment #19
andypostThere was suggestion to copy bin on module install