Skip to content

Commit c1a6a25

Browse files
committed
Issue #3419356 by taraskorpach, acbramley: Use constructor property promotion on $serializer in Drupal\Core\Cache\DatabaseBackend
1 parent 7bdf69b commit c1a6a25

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

lib/Drupal/Core/Cache/DatabaseBackend.php

+6-14
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,6 @@ class DatabaseBackend implements CacheBackendInterface {
6767
*/
6868
protected $checksumProvider;
6969

70-
/**
71-
* The serializer to use.
72-
*
73-
* @var \Drupal\Component\Serialization\ObjectAwareSerializationInterface
74-
*/
75-
protected ObjectAwareSerializationInterface $serializer;
76-
7770
/**
7871
* Constructs a DatabaseBackend object.
7972
*
@@ -93,7 +86,7 @@ public function __construct(
9386
Connection $connection,
9487
CacheTagsChecksumInterface $checksum_provider,
9588
$bin,
96-
ObjectAwareSerializationInterface|int|string|null $serializer = NULL,
89+
protected ObjectAwareSerializationInterface|int|string|null $serializer = NULL,
9790
$max_rows = NULL,
9891
) {
9992
// All cache tables should be prefixed with 'cache_'.
@@ -102,16 +95,15 @@ public function __construct(
10295
$this->bin = $bin;
10396
$this->connection = $connection;
10497
$this->checksumProvider = $checksum_provider;
105-
if (is_int($serializer) || is_string($serializer)) {
98+
if (is_int($this->serializer) || is_string($this->serializer)) {
10699
@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);
107-
$max_rows = $serializer;
108-
$serializer = \Drupal::service('serialization.phpserialize');
100+
$max_rows = $this->serializer;
101+
$this->serializer = \Drupal::service('serialization.phpserialize');
109102
}
110-
elseif ($serializer === NULL) {
103+
elseif ($this->serializer === NULL) {
111104
@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);
112-
$serializer = \Drupal::service('serialization.phpserialize');
105+
$this->serializer = \Drupal::service('serialization.phpserialize');
113106
}
114-
$this->serializer = $serializer;
115107
$this->maxRows = $max_rows === NULL ? static::DEFAULT_MAX_ROWS : $max_rows;
116108
}
117109

0 commit comments

Comments
 (0)