diff -u b/core/core.services.yml b/core/core.services.yml --- b/core/core.services.yml +++ b/core/core.services.yml @@ -201,7 +201,6 @@ arguments: ['@cache_tags.invalidator.checksum'] cache.backend.memory: class: Drupal\Core\Cache\MemoryBackendFactory - arguments: ['@serialization.phpserialize'] # A special cache bin that does not persist beyond the length of the request. cache.static: class: Drupal\Core\Cache\CacheBackendInterface reverted: --- b/core/lib/Drupal/Component/Serialization/ObjectSerializationInterface.php +++ /dev/null @@ -1,9 +0,0 @@ -serializer = $serializer; $this->connection = $connection; $this->checksumProvider = $checksum_provider; reverted: --- b/core/lib/Drupal/Core/Cache/MemoryBackend.php +++ a/core/lib/Drupal/Core/Cache/MemoryBackend.php @@ -2,9 +2,6 @@ namespace Drupal\Core\Cache; -use Drupal\Component\Serialization\ObjectSerializationInterface; -use Drupal\Core\DependencyInjection\DependencySerializationTrait; - /** * Defines a memory cache implementation. * @@ -17,33 +14,12 @@ */ class MemoryBackend implements CacheBackendInterface, CacheTagsInvalidatorInterface { - use DependencySerializationTrait { - __sleep as traitSleep; - } - - /** - * The serialization class to use. - * - * @var \Drupal\Component\Serialization\ObjectSerializationInterface - */ - protected $serializer; - /** * Array to store cache objects. */ protected $cache = array(); /** - * Constructs a MemoryBackend object. - * - * @param \Drupal\Component\Serialization\ObjectSerializationInterface $serializer - * The serialization class to use. - */ - public function __construct(ObjectSerializationInterface $serializer) { - $this->serializer = $serializer; - } - - /** * {@inheritdoc} */ public function get($cid, $allow_invalid = FALSE) { @@ -97,11 +73,11 @@ } // The object passed into this function is the one stored in $this->cache. // We must clone it as part of the preparation step so that the actual + // cache object is not affected by the unserialize() call or other + // manipulations of the returned object. - // cache object is not affected by the decode() call or other manipulations - // of the returned object. $prepared = clone $cache; + $prepared->data = unserialize($prepared->data); - $prepared->data = $this->serializer->decode($prepared->data); // Check expire time. $prepared->valid = $prepared->expire == Cache::PERMANENT || $prepared->expire >= $this->getRequestTime(); @@ -123,7 +99,7 @@ sort($tags); $this->cache[$cid] = (object) array( 'cid' => $cid, + 'data' => serialize($data), - 'data' => $this->serializer->encode($data), 'created' => $this->getRequestTime(), 'expire' => $expire, 'tags' => $tags, @@ -226,9 +202,7 @@ * Prevents data stored in memory backends from being serialized. */ public function __sleep() { + return []; - // The injected serializer service needs to be recovered. - $this->traitSleep(); - return ['_serviceIds']; } /** reverted: --- b/core/lib/Drupal/Core/Cache/MemoryBackendFactory.php +++ a/core/lib/Drupal/Core/Cache/MemoryBackendFactory.php @@ -2,18 +2,9 @@ namespace Drupal\Core\Cache; -use Drupal\Component\Serialization\ObjectSerializationInterface; - class MemoryBackendFactory implements CacheFactoryInterface { /** - * The serialization class to use. - * - * @var \Drupal\Component\Serialization\ObjectSerializationInterface - */ - protected $serializer; - - /** * Instantiated memory cache bins. * * @var \Drupal\Core\Cache\MemoryBackend[] @@ -21,21 +12,11 @@ protected $bins = array(); /** - * Constructs the MemoryBackendFactory object. - * - * @param \Drupal\Component\Serialization\ObjectSerializationInterface $serializer - * The serialization class to use. - */ - function __construct(ObjectSerializationInterface $serializer) { - $this->serializer = $serializer; - } - - /** * {@inheritdoc} */ function get($bin) { if (!isset($this->bins[$bin])) { + $this->bins[$bin] = new MemoryBackend(); - $this->bins[$bin] = new MemoryBackend($this->serializer); } return $this->bins[$bin]; } reverted: --- b/core/lib/Drupal/Core/Config/StorageComparer.php +++ a/core/lib/Drupal/Core/Config/StorageComparer.php @@ -99,15 +99,14 @@ * The configuration manager. */ public function __construct(StorageInterface $source_storage, StorageInterface $target_storage, ConfigManagerInterface $config_manager) { - $php_serialize = \Drupal::service('serialization.phpserialize'); // Wrap the storages in a static cache so that multiple reads of the same // raw configuration object are not costly. + $this->sourceCacheStorage = new MemoryBackend(); - $this->sourceCacheStorage = new MemoryBackend($php_serialize); $this->sourceStorage = new CachedStorage( $source_storage, $this->sourceCacheStorage ); + $this->targetCacheStorage = new MemoryBackend(); - $this->targetCacheStorage = new MemoryBackend($php_serialize); $this->targetStorage = new CachedStorage( $target_storage, $this->targetCacheStorage reverted: --- b/core/lib/Drupal/Core/Installer/InstallerServiceProvider.php +++ a/core/lib/Drupal/Core/Installer/InstallerServiceProvider.php @@ -28,11 +28,9 @@ // Replace services with in-memory implementations. $definition = $container->getDefinition('cache_factory'); $definition->setClass('Drupal\Core\Cache\MemoryBackendFactory'); + $definition->setArguments(array()); - $definition->setArguments([new Reference('serialization.phpserialize')]); $definition->setMethodCalls(array()); $container - ->register('serialization.phpserialize', 'Drupal\Component\Serialization\PhpSerialize'); - $container ->register('keyvalue', 'Drupal\Core\KeyValueStore\KeyValueMemoryFactory'); $container ->register('keyvalue.expirable', 'Drupal\Core\KeyValueStore\KeyValueNullExpirableFactory'); reverted: --- b/core/modules/hal/tests/src/Kernel/FileNormalizeTest.php +++ a/core/modules/hal/tests/src/Kernel/FileNormalizeTest.php @@ -2,7 +2,6 @@ namespace Drupal\Tests\hal\Kernel; -use Drupal\Component\Serialization\PhpSerialize; use Drupal\Core\Cache\MemoryBackend; use Drupal\file\Entity\File; use Drupal\hal\Encoder\JsonEncoder; @@ -36,8 +35,7 @@ $this->installEntitySchema('file'); $entity_manager = \Drupal::entityManager(); + $link_manager = new LinkManager(new TypeLinkManager(new MemoryBackend(), \Drupal::moduleHandler(), \Drupal::service('config.factory'), \Drupal::service('request_stack'), \Drupal::service('entity_type.bundle.info')), new RelationLinkManager(new MemoryBackend(), $entity_manager, \Drupal::moduleHandler(), \Drupal::service('config.factory'), \Drupal::service('request_stack'))); - $php_serialize = new PhpSerialize(); - $link_manager = new LinkManager(new TypeLinkManager(new MemoryBackend($php_serialize), \Drupal::moduleHandler(), \Drupal::service('config.factory'), \Drupal::service('request_stack'), \Drupal::service('entity_type.bundle.info')), new RelationLinkManager(new MemoryBackend($php_serialize), $entity_manager, \Drupal::moduleHandler(), \Drupal::service('config.factory'), \Drupal::service('request_stack'))); // Set up the mock serializer. $normalizers = array( reverted: --- b/core/modules/hal/tests/src/Kernel/NormalizerTestBase.php +++ a/core/modules/hal/tests/src/Kernel/NormalizerTestBase.php @@ -2,7 +2,6 @@ namespace Drupal\Tests\hal\Kernel; -use Drupal\Component\Serialization\PhpSerialize; use Drupal\Core\Cache\MemoryBackend; use Drupal\field\Entity\FieldConfig; use Drupal\hal\Encoder\JsonEncoder; @@ -132,8 +131,7 @@ ])->save(); $entity_manager = \Drupal::entityManager(); + $link_manager = new LinkManager(new TypeLinkManager(new MemoryBackend(), \Drupal::moduleHandler(), \Drupal::service('config.factory'), \Drupal::service('request_stack'), \Drupal::service('entity_type.bundle.info')), new RelationLinkManager(new MemoryBackend(), $entity_manager, \Drupal::moduleHandler(), \Drupal::service('config.factory'), \Drupal::service('request_stack'))); - $php_serialize = new PhpSerialize(); - $link_manager = new LinkManager(new TypeLinkManager(new MemoryBackend($php_serialize), \Drupal::moduleHandler(), \Drupal::service('config.factory'), \Drupal::service('request_stack'), \Drupal::service('entity_type.bundle.info')), new RelationLinkManager(new MemoryBackend($php_serialize), $entity_manager, \Drupal::moduleHandler(), \Drupal::service('config.factory'), \Drupal::service('request_stack'))); $chain_resolver = new ChainEntityResolver(array(new UuidResolver($entity_manager), new TargetIdResolver())); reverted: --- b/core/modules/simpletest/src/KernelTestBase.php +++ a/core/modules/simpletest/src/KernelTestBase.php @@ -313,10 +313,7 @@ $this->container->setParameter('language.default_values', $this->defaultLanguageData()); $container->register('lock', 'Drupal\Core\Lock\NullLockBackend'); + $container->register('cache_factory', 'Drupal\Core\Cache\MemoryBackendFactory'); - $container->register('serialization.phpserialize', 'Drupal\Component\Serialization\PhpSerialize'); - $container - ->register('cache_factory', 'Drupal\Core\Cache\MemoryBackendFactory') - ->addArgument(new Reference('serialization.phpserialize')); $container ->register('config.storage', 'Drupal\Core\Config\DatabaseStorage') reverted: --- b/core/modules/simpletest/src/Tests/SimpleTestTest.php +++ a/core/modules/simpletest/src/Tests/SimpleTestTest.php @@ -90,7 +90,6 @@ # Swap out a core service. cache.backend.database: class: Drupal\Core\Cache\MemoryBackendFactory - arguments: ['@serialization.phpserialize'] EOD; file_put_contents($this->siteDirectory . '/testing.services.yml', $yaml); reverted: --- b/core/tests/Drupal/KernelTests/Core/Cache/BackendChainTest.php +++ a/core/tests/Drupal/KernelTests/Core/Cache/BackendChainTest.php @@ -17,9 +17,9 @@ // We need to create some various backends in the chain. $chain + ->appendBackend(new MemoryBackend()) + ->prependBackend(new MemoryBackend()) + ->appendBackend(new MemoryBackend()); - ->appendBackend(new MemoryBackend(\Drupal::service('serialization.phpserialize'))) - ->prependBackend(new MemoryBackend(\Drupal::service('serialization.phpserialize'))) - ->appendBackend(new MemoryBackend(\Drupal::service('serialization.phpserialize'))); \Drupal::service('cache_tags.invalidator')->addInvalidator($chain); reverted: --- b/core/tests/Drupal/KernelTests/Core/Cache/MemoryBackendTest.php +++ a/core/tests/Drupal/KernelTests/Core/Cache/MemoryBackendTest.php @@ -18,7 +18,7 @@ * A new MemoryBackend object. */ protected function createCacheBackend($bin) { + $backend = new MemoryBackend(); - $backend = new MemoryBackend(\Drupal::service('serialization.phpserialize')); \Drupal::service('cache_tags.invalidator')->addInvalidator($backend); return $backend; } reverted: --- b/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelSiteTest.php +++ a/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelSiteTest.php @@ -34,7 +34,6 @@ # Swap out a core service. cache.backend.database: class: Drupal\Core\Cache\MemoryBackendFactory - arguments: ['@serialization.phpserialize'] EOD; file_put_contents($this->siteDirectory . '/services.yml', $doc); reverted: --- b/core/tests/Drupal/KernelTests/Core/Path/AliasTest.php +++ a/core/tests/Drupal/KernelTests/Core/Path/AliasTest.php @@ -2,7 +2,6 @@ namespace Drupal\KernelTests\Core\Path; -use Drupal\Component\Serialization\PhpSerialize; use Drupal\Core\Cache\MemoryCounterBackend; use Drupal\Core\Path\AliasStorage; use Drupal\Core\Database\Database; @@ -161,7 +160,7 @@ $connection = Database::getConnection(); $this->fixtures->createTables($connection); + $memoryCounterBackend = new MemoryCounterBackend(); - $memoryCounterBackend = new MemoryCounterBackend(new PhpSerialize()); // Create AliasManager and Path object. $aliasStorage = new AliasStorage($connection, $this->container->get('module_handler')); reverted: --- b/core/tests/Drupal/KernelTests/Core/Plugin/PluginTestBase.php +++ a/core/tests/Drupal/KernelTests/Core/Plugin/PluginTestBase.php @@ -2,7 +2,6 @@ namespace Drupal\KernelTests\Core\Plugin; -use Drupal\Component\Serialization\PhpSerialize; use Drupal\Core\Plugin\Context\ContextDefinition; use Drupal\KernelTests\KernelTestBase; use Drupal\plugin_test\Plugin\TestPluginManager; @@ -43,7 +42,7 @@ // as derivatives and ReflectionFactory. $this->testPluginManager = new TestPluginManager(); $this->mockBlockManager = new MockBlockManager(); + $module_handler = new ModuleHandler(\Drupal::root(), array(), new MemoryBackend(), $this->container->get('event_dispatcher')); - $module_handler = new ModuleHandler(\Drupal::root(), array(), new MemoryBackend(new PhpSerialize()), $this->container->get('event_dispatcher')); $this->defaultsTestPluginManager = new DefaultsTestPluginManager($module_handler); // The expected plugin definitions within each manager. Several tests assert reverted: --- b/core/tests/Drupal/KernelTests/Core/Routing/MatcherDumperTest.php +++ a/core/tests/Drupal/KernelTests/Core/Routing/MatcherDumperTest.php @@ -2,7 +2,6 @@ namespace Drupal\KernelTests\Core\Routing; -use Drupal\Component\Serialization\PhpSerialize; use Drupal\Core\Cache\MemoryBackend; use Drupal\Core\KeyValueStore\KeyValueMemoryFactory; use Drupal\Core\Lock\NullLockBackend; @@ -39,7 +38,7 @@ parent::setUp(); $this->fixtures = new RoutingFixtures(); + $this->state = new State(new KeyValueMemoryFactory(), new MemoryBackend('test'), new NullLockBackend()); - $this->state = new State(new KeyValueMemoryFactory(), new MemoryBackend(new PhpSerialize()), new NullLockBackend()); } /** reverted: --- b/core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php +++ a/core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php @@ -7,7 +7,6 @@ namespace Drupal\KernelTests\Core\Routing; -use Drupal\Component\Serialization\PhpSerialize; use Drupal\Core\Cache\MemoryBackend; use Drupal\Core\Database\Database; use Drupal\Core\DependencyInjection\ContainerBuilder; @@ -83,9 +82,9 @@ protected function setUp() { parent::setUp(); $this->fixtures = new RoutingFixtures(); + $this->state = new State(new KeyValueMemoryFactory(), new MemoryBackend('test'), new NullLockBackend()); - $this->state = new State(new KeyValueMemoryFactory(), new MemoryBackend(new PhpSerialize()), new NullLockBackend()); $this->currentPath = new CurrentPathStack(new RequestStack()); + $this->cache = new MemoryBackend(); - $this->cache = new MemoryBackend(new PhpSerialize()); $this->pathProcessor = \Drupal::service('path_processor_manager'); $this->cacheTagsInvalidator = \Drupal::service('cache_tags.invalidator'); } reverted: --- b/core/tests/Drupal/KernelTests/KernelTestBase.php +++ a/core/tests/Drupal/KernelTests/KernelTestBase.php @@ -596,10 +596,7 @@ $container ->register('lock', 'Drupal\Core\Lock\NullLockBackend'); $container + ->register('cache_factory', 'Drupal\Core\Cache\MemoryBackendFactory'); - ->register('serialization.phpserialize', 'Drupal\Component\Serialization\PhpSerialize'); - $container - ->register('cache_factory', 'Drupal\Core\Cache\MemoryBackendFactory') - ->addArgument(new Reference('serialization.phpserialize')); $container ->register('keyvalue.memory', 'Drupal\Core\KeyValueStore\KeyValueMemoryFactory') // Must persist container rebuilds, or all data would vanish otherwise. reverted: --- b/core/tests/Drupal/Tests/Core/Asset/AssetResolverTest.php +++ a/core/tests/Drupal/Tests/Core/Asset/AssetResolverTest.php @@ -7,7 +7,6 @@ namespace Drupal\Tests\Core\Asset; -use Drupal\Component\Serialization\PhpSerialize; use Drupal\Core\Asset\AssetResolver; use Drupal\Core\Asset\AttachedAssets; use Drupal\Core\Asset\AttachedAssetsInterface; @@ -107,7 +106,7 @@ $this->languageManager->expects($this->any()) ->method('getCurrentLanguage') ->will($this->onConsecutiveCalls($english, $english, $japanese, $japanese)); + $this->cache = new TestMemoryBackend(); - $this->cache = new TestMemoryBackend(new PhpSerialize()); $this->assetResolver = new AssetResolver($this->libraryDiscovery, $this->libraryDependencyResolver, $this->moduleHandler, $this->themeManager, $this->languageManager, $this->cache); } reverted: --- b/core/tests/Drupal/Tests/Core/Cache/BackendChainImplementationUnitTest.php +++ a/core/tests/Drupal/Tests/Core/Cache/BackendChainImplementationUnitTest.php @@ -2,7 +2,6 @@ namespace Drupal\Tests\Core\Cache; -use Drupal\Component\Serialization\PhpSerialize; use Drupal\Core\Cache\BackendChain; use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\MemoryBackend; @@ -46,11 +45,10 @@ protected function setUp() { parent::setUp(); - $php_serialize = new PhpSerialize(); // Set up three memory backends to be used in the chain. + $this->firstBackend = new MemoryBackend(); + $this->secondBackend = new MemoryBackend(); + $this->thirdBackend = new MemoryBackend(); - $this->firstBackend = new MemoryBackend($php_serialize); - $this->secondBackend = new MemoryBackend($php_serialize); - $this->thirdBackend = new MemoryBackend($php_serialize); // Set an initial fixed dataset for all testing. The next three data // collections will test two edge cases (last backend has the data, and reverted: --- b/core/tests/Drupal/Tests/Core/Cache/ChainedFastBackendTest.php +++ a/core/tests/Drupal/Tests/Core/Cache/ChainedFastBackendTest.php @@ -2,7 +2,6 @@ namespace Drupal\Tests\Core\Cache; -use Drupal\Component\Serialization\PhpSerialize; use Drupal\Core\Cache\ChainedFastBackend; use Drupal\Core\Cache\MemoryBackend; use Drupal\Tests\UnitTestCase; @@ -48,7 +47,7 @@ $consistent_cache->expects($this->never()) ->method('getMultiple'); + $fast_cache = new MemoryBackend(); - $fast_cache = new MemoryBackend(new PhpSerialize()); $fast_cache->set('foo', 'baz'); $chained_fast_backend = new ChainedFastBackend( reverted: --- b/core/tests/Drupal/Tests/Core/Config/StorageComparerTest.php +++ a/core/tests/Drupal/Tests/Core/Config/StorageComparerTest.php @@ -2,7 +2,6 @@ namespace Drupal\Tests\Core\Config; -use Drupal\Component\Serialization\PhpSerialize; use Drupal\Component\Uuid\Php; use Drupal\Core\Config\StorageComparer; use Drupal\Tests\UnitTestCase; @@ -46,12 +45,6 @@ $this->sourceStorage = $this->getMock('Drupal\Core\Config\StorageInterface'); $this->targetStorage = $this->getMock('Drupal\Core\Config\StorageInterface'); $this->configManager = $this->getMock('Drupal\Core\Config\ConfigManagerInterface'); - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); - $container->expects($this->any()) - ->method('get') - ->with('serialization.phpserialize') - ->willReturn(new PhpSerialize()); - \Drupal::setContainer($container); $this->storageComparer = new StorageComparer($this->sourceStorage, $this->targetStorage, $this->configManager); } reverted: --- b/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php +++ a/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php @@ -7,7 +7,6 @@ namespace Drupal\Tests\Core\Extension; -use Drupal\Component\Serialization\PhpSerialize; use Drupal\Core\Cache\MemoryBackend; use Drupal\Core\Extension\Extension; use Drupal\Core\Extension\InfoParser; @@ -81,7 +80,7 @@ ), )); $this->moduleHandler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface'); + $this->state = new State(new KeyValueMemoryFactory(), new MemoryBackend('test'), new NullLockBackend()); - $this->state = new State(new KeyValueMemoryFactory(), new MemoryBackend(new PhpSerialize()), new NullLockBackend()); $this->infoParser = $this->getMock('Drupal\Core\Extension\InfoParserInterface'); $this->extensionDiscovery = $this->getMockBuilder('Drupal\Core\Extension\ExtensionDiscovery') ->disableOriginalConstructor() reverted: --- b/core/tests/Drupal/Tests/Core/Render/RendererBubblingTest.php +++ a/core/tests/Drupal/Tests/Core/Render/RendererBubblingTest.php @@ -7,7 +7,6 @@ namespace Drupal\Tests\Core\Render; -use Drupal\Component\Serialization\PhpSerialize; use Drupal\Core\Cache\MemoryBackend; use Drupal\Core\KeyValueStore\KeyValueMemoryFactory; use Drupal\Core\Lock\NullLockBackend; @@ -81,9 +80,8 @@ $bin = $this->randomMachineName(); $this->setUpRequest(); + $this->memoryCache = new MemoryBackend(); + $custom_cache = new MemoryBackend(); - $php_serialize = new PhpSerialize(); - $this->memoryCache = new MemoryBackend($php_serialize); - $custom_cache = new MemoryBackend($php_serialize); $this->cacheFactory->expects($this->atLeastOnce()) ->method('get') @@ -505,7 +503,7 @@ $this->setupMemoryCache(); // Mock the State service. + $memory_state = new State(new KeyValueMemoryFactory(), new MemoryBackend('test'), new NullLockBackend()); - $memory_state = new State(new KeyValueMemoryFactory(), new MemoryBackend(new PhpSerialize()), new NullLockBackend()); \Drupal::getContainer()->set('state', $memory_state); $this->controllerResolver->expects($this->any()) ->method('getControllerFromDefinition') reverted: --- b/core/tests/Drupal/Tests/Core/Render/RendererTestBase.php +++ a/core/tests/Drupal/Tests/Core/Render/RendererTestBase.php @@ -7,7 +7,6 @@ namespace Drupal\Tests\Core\Render; -use Drupal\Component\Serialization\PhpSerialize; use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Cache\Context\ContextCacheKeys; @@ -209,7 +208,7 @@ * Sets up a memory-based render cache back-end. */ protected function setupMemoryCache() { + $this->memoryCache = $this->memoryCache ?: new MemoryBackend(); - $this->memoryCache = $this->memoryCache ?: new MemoryBackend(new PhpSerialize()); $this->cacheFactory->expects($this->atLeastOnce()) ->method('get') only in patch2: unchanged: --- /dev/null +++ b/core/lib/Drupal/Component/Serialization/ObjectAwareSerializationInterface.php @@ -0,0 +1,9 @@ +