From 1bcfd82ce8930d1ef27548b33fd584e06d7c9c7d Mon Sep 17 00:00:00 2001 From: Lee Rowlands <lee.rowlands@previousnext.com.au> Date: Wed, 7 Feb 2024 08:43:10 +1000 Subject: [PATCH] Issue #3419352 by acbramley: DatabaseBackend doesn't handle string typed $max_rows with $serializer --- core/lib/Drupal/Core/Cache/DatabaseBackend.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/core/lib/Drupal/Core/Cache/DatabaseBackend.php b/core/lib/Drupal/Core/Cache/DatabaseBackend.php index 7a36c5612c91..be8cf52e3ad1 100644 --- a/core/lib/Drupal/Core/Cache/DatabaseBackend.php +++ b/core/lib/Drupal/Core/Cache/DatabaseBackend.php @@ -83,20 +83,26 @@ class DatabaseBackend implements CacheBackendInterface { * The cache tags checksum provider. * @param string $bin * The cache bin for which the object is created. - * @param \Drupal\Component\Serialization\ObjectAwareSerializationInterface|int|null $serializer + * @param \Drupal\Component\Serialization\ObjectAwareSerializationInterface|int|string|null $serializer * (optional) The serializer to use. * @param int $max_rows * (optional) The maximum number of rows that are allowed in this cache bin * table. */ - public function __construct(Connection $connection, CacheTagsChecksumInterface $checksum_provider, $bin, ObjectAwareSerializationInterface|int $serializer = NULL, $max_rows = NULL) { + public function __construct( + Connection $connection, + CacheTagsChecksumInterface $checksum_provider, + $bin, + ObjectAwareSerializationInterface|int|string|null $serializer = NULL, + $max_rows = NULL, + ) { // All cache tables should be prefixed with 'cache_'. $bin = 'cache_' . $bin; $this->bin = $bin; $this->connection = $connection; $this->checksumProvider = $checksum_provider; - if (is_int($serializer)) { + if (is_int($serializer) || is_string($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); $max_rows = $serializer; $serializer = \Drupal::service('serialization.phpserialize'); -- GitLab