diff -u b/core/includes/bootstrap.inc b/core/includes/bootstrap.inc --- b/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -2457,13 +2457,22 @@ ->addArgument('slave') ->addArgument(NULL) ->addArgument('%database.info%'); - $container->register('cache', 'Drupal\Core\Cache\DatabaseBackend') - ->addArgument('cache') - ->addArgument(new Reference('database')) - ->addTag('cache'); + // settings.php might have registered an alternative cache implementation + // already. + if (!$container->has('cache')) { + $container->register('cache', 'Drupal\Core\Cache\DatabaseBackend') + ->addArgument('cache') + ->addArgument(new Reference('database')) + ->addTag('cache'); + } foreach (array('bootstrap', 'config', 'page') as $bin) { - $definition = clone $container->getDefinition('cache'); - $container->setDefinition('cache.' . $bin, $definition->replaceArgument(0, $bin)); + $id = 'cache.' . $bin; + if (!$container->has($id)) { + // A clone is necessary otherwise the replaceArgument call would change + // every definition. + $definition = clone $container->getDefinition('cache'); + $container->setDefinition($id, $definition->replaceArgument(0, $bin)); + } } $container