diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 1c5cfb1..cd9cf11 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -2464,12 +2464,14 @@ function drupal_container(Container $new_container = NULL, $rebuild = FALSE) { ->addArgument(NULL) ->addArgument('%database.info%'); $container->register('cache', 'Drupal\Core\Cache\DatabaseBackend') + ->addArgument('cache') ->addArgument(new Reference('database')) - ->addArgument('cache'); - foreach (array('bootstrap', 'block', 'config', 'field', 'filter', 'form', 'page', 'menu', 'path', 'test') as $bin) { + ->addTag('cache'); + foreach (array('bootstrap', 'config') as $bin) { $container->register('cache.' . $bin, 'Drupal\Core\Cache\DatabaseBackend') + ->addArgument($bin) ->addArgument(new Reference('database')) - ->addArgument($bin); + ->addTag('cache'); } $container diff --git a/core/includes/cache.inc b/core/includes/cache.inc index eba7736..7664858 100644 --- a/core/includes/cache.inc +++ b/core/includes/cache.inc @@ -36,8 +36,9 @@ function cache($bin = 'cache') { * The list of tags to invalidate cache items for. */ function cache_invalidate(array $tags) { - foreach (cache_backends() as $backend) { - $backend->invalidateTags($tags); + $container = drupal_container(); + foreach (cache_backends() as $name) { + $container->get($name)->invalidateTags($tags); } } @@ -45,16 +46,8 @@ function cache_invalidate(array $tags) { * Returns a list of cache backends for this site. * * @return array - * An associative array with cache bins as keys, and backend object as the - * value. + * An array of cache backend service names. */ function cache_backends() { - $container = drupal_container(); - $cache_services = array_filter($container->getServiceIds(), function ($value) { return substr($value, 0, 6) == 'cache.';}); - $cache_services[] = 'cache'; - $backends = array(); - foreach ($cache_services as $service) { - $backends[$service] = $container->get($service); - } - return $backends; -} \ No newline at end of file + return array_keys(drupal_container()->findTaggedServiceIds('cache')); +} diff --git a/core/lib/Drupal/Core/Cache/DatabaseBackend.php b/core/lib/Drupal/Core/Cache/DatabaseBackend.php index 990608d..3aea56f 100644 --- a/core/lib/Drupal/Core/Cache/DatabaseBackend.php +++ b/core/lib/Drupal/Core/Cache/DatabaseBackend.php @@ -36,12 +36,12 @@ class DatabaseBackend implements CacheBackendInterface { /** * Constructs a new cache database backend. * - * @param Drupal\Core\Database\Connection $connection - * The database connection that should be used. * @param string $bin * (optional) The cache bin that should be used. + * @param Drupal\Core\Database\Connection $connection + * The database connection that should be used. */ - function __construct(Connection $connection, $bin) { + function __construct($bin, Connection $connection) { $this->dbConnection = $connection; if ($bin != 'cache') { $bin = 'cache_' . $bin; diff --git a/core/lib/Drupal/Core/CoreBundle.php b/core/lib/Drupal/Core/CoreBundle.php index 72d2703..25cbb63 100644 --- a/core/lib/Drupal/Core/CoreBundle.php +++ b/core/lib/Drupal/Core/CoreBundle.php @@ -47,6 +47,16 @@ public function build(ContainerBuilder $container) { ->addArgument(new Reference('request')) ->setScope('request'); + foreach (array('block', 'field', 'filter', 'form', 'page', 'menu', 'path', 'test') as $bin) { + $id = 'cache.' . $bin; + // Only define the bin if it has not yet been defined. + if (!$container->has($id)) { + $definition = clone $container->getDefinition('cache'); + // Each backend must define the bin as it's first constructor argument. + $container->setDefinition($id, $definition->replaceArgument(0, $bin)); + } + } + $container->register('typed_data', 'Drupal\Core\TypedData\TypedDataManager'); // Add the user's storage for temporary, non-cache data. $container->register('lock', 'Drupal\Core\Lock\DatabaseLockBackend'); diff --git a/core/update.php b/core/update.php index 20e1153..4ead949 100644 --- a/core/update.php +++ b/core/update.php @@ -268,8 +268,13 @@ function update_info_page() { _drupal_flush_css_js(); // Flush the cache of all data for the update status module. if (db_table_exists('cache_update')) { - // @todo: Change to KV once converted. - db_truncate('cache_update')->execute(); + $query = db_delete('cache_update'); + $query->condition( + db_or() + ->condition('cid', 'update_project_%', 'LIKE') + ->condition('cid', 'available_releases::%', 'LIKE') + ); + $query->execute(); } update_task_list('info');