diff -u b/core/lib/Drupal/Core/Cache/DatabaseBackend.php b/core/lib/Drupal/Core/Cache/DatabaseBackend.php --- b/core/lib/Drupal/Core/Cache/DatabaseBackend.php +++ b/core/lib/Drupal/Core/Cache/DatabaseBackend.php @@ -10,6 +10,7 @@ use Drupal\Component\Utility\Crypt; use Drupal\Core\Database\Connection; use Drupal\Core\Database\SchemaObjectExistsException; +use Drupal\Component\Transliteration\TransliterationInterface; /** * Defines a default cache implementation. @@ -42,21 +43,31 @@ protected $checksumProvider; /** + * The transliteration service. + * + * @var \Drupal\Component\Transliteration\TransliterationInterface + */ + protected $transliteration; + + /** * Constructs a DatabaseBackend object. * * @param \Drupal\Core\Database\Connection $connection * The database connection. * @param \Drupal\Core\Cache\CacheTagsChecksumInterface $checksum_provider * The cache tags checksum provider. + * @param \Drupal\Component\Transliteration\TransliterationInterface $transliteration + * The transliteration service. * @param string $bin * The cache bin for which the object is created. */ - public function __construct(Connection $connection, CacheTagsChecksumInterface $checksum_provider, $bin) { + public function __construct(Connection $connection, CacheTagsChecksumInterface $checksum_provider, TransliterationInterface $transliteration, $bin) { // All cache tables should be prefixed with 'cache_'. $bin = 'cache_' . $bin; $this->bin = $bin; $this->connection = $connection; + $this->transliteration = $transliteration; $this->checksumProvider = $checksum_provider; } @@ -419,16 +430,20 @@ * The passed in cache ID. * * @return string - * A cache ID that is at most 255 characters long. + * An ASCII-encoded cache ID that is at most 255 characters long. */ protected function normalizeCid($cid) { - // Nothing to do if the ID length is 255 characters or less. - if (strlen($cid) <= 255) { + // Nothing to do if the ID is a US ASCII string of 255 characters or less. + $cid_is_ascii = mb_check_encoding($cid, 'ASCII'); + if (strlen($cid) <= 255 && $is_ascii === TRUE) { return $cid; } // Return a string that uses as much as possible of the original cache ID // with the hash appended. $hash = Crypt::hashBase64($cid); + if (!$cid_is_ascii) { + $cid = $this->transliteration->transliterate($cid); + } return substr($cid, 0, 255 - strlen($hash)) . $hash; } only in patch2: unchanged: --- a/core/core.services.yml +++ b/core/core.services.yml @@ -133,7 +133,7 @@ services: - [setContainer, ['@service_container']] cache.backend.database: class: Drupal\Core\Cache\DatabaseBackendFactory - arguments: ['@database', '@cache_tags.invalidator.checksum'] + arguments: ['@database', '@cache_tags.invalidator.checksum', '@transliteration'] cache.backend.apcu: class: Drupal\Core\Cache\ApcuBackendFactory arguments: ['@app.root', '@cache_tags.invalidator.checksum']