Skip to content
Snippets Groups Projects
Verified Commit 5ce8edea authored by Dave Long's avatar Dave Long
Browse files

Issue #3419356 by taraskorpach, acbramley: Use constructor property promotion...

Issue #3419356 by taraskorpach, acbramley: Use constructor property promotion on $serializer in Drupal\Core\Cache\DatabaseBackend
parent 19dfeb4f
No related branches found
No related tags found
No related merge requests found
...@@ -67,13 +67,6 @@ class DatabaseBackend implements CacheBackendInterface { ...@@ -67,13 +67,6 @@ class DatabaseBackend implements CacheBackendInterface {
*/ */
protected $checksumProvider; protected $checksumProvider;
/**
* The serializer to use.
*
* @var \Drupal\Component\Serialization\ObjectAwareSerializationInterface
*/
protected ObjectAwareSerializationInterface $serializer;
/** /**
* Constructs a DatabaseBackend object. * Constructs a DatabaseBackend object.
* *
...@@ -93,7 +86,7 @@ public function __construct( ...@@ -93,7 +86,7 @@ public function __construct(
Connection $connection, Connection $connection,
CacheTagsChecksumInterface $checksum_provider, CacheTagsChecksumInterface $checksum_provider,
$bin, $bin,
ObjectAwareSerializationInterface|int|string|null $serializer = NULL, protected ObjectAwareSerializationInterface|int|string|null $serializer = NULL,
$max_rows = NULL, $max_rows = NULL,
) { ) {
// All cache tables should be prefixed with 'cache_'. // All cache tables should be prefixed with 'cache_'.
...@@ -102,16 +95,15 @@ public function __construct( ...@@ -102,16 +95,15 @@ public function __construct(
$this->bin = $bin; $this->bin = $bin;
$this->connection = $connection; $this->connection = $connection;
$this->checksumProvider = $checksum_provider; $this->checksumProvider = $checksum_provider;
if (is_int($serializer) || is_string($serializer)) { if (is_int($this->serializer) || is_string($this->serializer)) {
@trigger_error('Calling ' . __METHOD__ . ' with the $max_rows as 3rd argument is deprecated in drupal:10.3.0 and it will be the 4th argument in drupal:11.0.0. See https://www.drupal.org/node/3014684', E_USER_DEPRECATED); @trigger_error('Calling ' . __METHOD__ . ' with the $max_rows as 3rd argument is deprecated in drupal:10.3.0 and it will be the 4th argument in drupal:11.0.0. See https://www.drupal.org/node/3014684', E_USER_DEPRECATED);
$max_rows = $serializer; $max_rows = $this->serializer;
$serializer = \Drupal::service('serialization.phpserialize'); $this->serializer = \Drupal::service('serialization.phpserialize');
} }
elseif ($serializer === NULL) { elseif ($this->serializer === NULL) {
@trigger_error('Calling ' . __METHOD__ . ' without the $serializer argument is deprecated in drupal:10.3.0 and it will be required in drupal:11.0.0. See https://www.drupal.org/node/3014684', E_USER_DEPRECATED); @trigger_error('Calling ' . __METHOD__ . ' without the $serializer argument is deprecated in drupal:10.3.0 and it will be required in drupal:11.0.0. See https://www.drupal.org/node/3014684', E_USER_DEPRECATED);
$serializer = \Drupal::service('serialization.phpserialize'); $this->serializer = \Drupal::service('serialization.phpserialize');
} }
$this->serializer = $serializer;
$this->maxRows = $max_rows === NULL ? static::DEFAULT_MAX_ROWS : $max_rows; $this->maxRows = $max_rows === NULL ? static::DEFAULT_MAX_ROWS : $max_rows;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment