diff --git a/core/lib/Drupal/Core/Cache/DatabaseBackend.php b/core/lib/Drupal/Core/Cache/DatabaseBackend.php index 52f7e13866..c5d6a0dc25 100644 --- a/core/lib/Drupal/Core/Cache/DatabaseBackend.php +++ b/core/lib/Drupal/Core/Cache/DatabaseBackend.php @@ -81,7 +81,7 @@ class DatabaseBackend implements CacheBackendInterface { * (optional) The maximum number of rows that are allowed in this cache bin * table. * @param \Drupal\Component\Serialization\ObjectAwareSerializationInterface $serializer - * The serializer to use. + * (optional) The serializer to use. */ public function __construct(Connection $connection, CacheTagsChecksumInterface $checksum_provider, $bin, $max_rows = NULL, ObjectAwareSerializationInterface $serializer = NULL) { // All cache tables should be prefixed with 'cache_'. @@ -91,13 +91,10 @@ public function __construct(Connection $connection, CacheTagsChecksumInterface $ $this->connection = $connection; $this->checksumProvider = $checksum_provider; $this->maxRows = $max_rows === NULL ? static::DEFAULT_MAX_ROWS : $max_rows; - if ($serializer) { - $this->serializer = $serializer; - } - else { - @trigger_error('The serializer service will be a mandatory parameter in Drupal 9.0.x. See https://www.drupal.org/node/3014688.', E_USER_DEPRECATED); - $this->serializer = \Drupal::service('serialization.phpserialize'); + if (!$serializer) { + @trigger_error('Calling DatabaseBackend::__construct() without the $serializer argument is deprecated in drupal:8.8.0. The $serializer argument will be required in drupal:9.0.0. See https://www.drupal.org/node/3014688', E_USER_DEPRECATED); } + $this->serializer = \Drupal::service('serialization.phpserialize'); } /** diff --git a/core/lib/Drupal/Core/Cache/DatabaseBackendFactory.php b/core/lib/Drupal/Core/Cache/DatabaseBackendFactory.php index 751f30f014..371227c8bc 100644 --- a/core/lib/Drupal/Core/Cache/DatabaseBackendFactory.php +++ b/core/lib/Drupal/Core/Cache/DatabaseBackendFactory.php @@ -46,7 +46,7 @@ class DatabaseBackendFactory implements CacheFactoryInterface { * @param \Drupal\Core\Site\Settings $settings * (optional) The site settings. * @param \Drupal\Component\Serialization\ObjectAwareSerializationInterface $serializer - * The serializer to use. + * (optional) The serializer to use. * * @throws \BadMethodCallException */ @@ -54,13 +54,10 @@ public function __construct(Connection $connection, CacheTagsChecksumInterface $ $this->connection = $connection; $this->checksumProvider = $checksum_provider; $this->settings = $settings ?: Settings::getInstance(); - if ($serializer) { - $this->serializer = $serializer; - } - else { - @trigger_error('The serializer service will be a mandatory parameter in Drupal 9.0.x. See https://www.drupal.org/node/3014688.', E_USER_DEPRECATED); - $this->serializer = \Drupal::service('serialization.phpserialize'); + if (!$serializer) { + @trigger_error('Calling DatabaseBackendFactory::__construct() without the $serializer argument is deprecated in drupal:8.8.0. The $serializer argument will be required in drupal:9.0.0. See https://www.drupal.org/node/3014688', E_USER_DEPRECATED); } + $this->serializer = \Drupal::service('serialization.phpserialize'); } /** diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php index 9cec85d2df..58d67cf00a 100644 --- a/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -82,7 +82,13 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface { ], 'cache.container' => [ 'class' => 'Drupal\Core\Cache\DatabaseBackend', - 'arguments' => ['@database', '@cache_tags_provider.container', 'container', DatabaseBackend::MAXIMUM_NONE, '@serialization.phpserialize'], + 'arguments' => [ + '@database', + '@cache_tags_provider.container', + 'container', + DatabaseBackend::MAXIMUM_NONE, + '@serialization.phpserialize', + ], ], 'cache_tags_provider.container' => [ 'class' => 'Drupal\Core\Cache\DatabaseCacheTagsChecksum',