From c523c9956783aa9371889f2100acf8156757a125 Mon Sep 17 00:00:00 2001 From: Alex Pott <alex.a.pott@googlemail.com> Date: Fri, 24 Jul 2015 16:24:12 +0100 Subject: [PATCH] Issue #2492429 by mikeryan: Migration count caching broken --- .../src/Plugin/migrate/source/SourcePluginBase.php | 4 ++-- core/modules/migrate/tests/src/Unit/MigrateSourceTest.php | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php b/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php index 2ebcbbad7607..51cdcda65ffc 100644 --- a/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php +++ b/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php @@ -423,7 +423,7 @@ public function count($refresh = FALSE) { // class to get the count from the source. if ($refresh || !$this->cacheCounts) { $count = $this->getIterator()->count(); - $this->getCache()->set($this->cacheKey, $count, 'cache'); + $this->getCache()->set($this->cacheKey, $count); } else { // Caching is in play, first try to retrieve a cached count. @@ -436,7 +436,7 @@ public function count($refresh = FALSE) { // No cached count, ask the derived class to count 'em up, and cache // the result. $count = $this->getIterator()->count(); - $this->getCache()->set($this->cacheKey, $count, 'cache'); + $this->getCache()->set($this->cacheKey, $count); } } return $count; diff --git a/core/modules/migrate/tests/src/Unit/MigrateSourceTest.php b/core/modules/migrate/tests/src/Unit/MigrateSourceTest.php index d6e726a8c8c0..72d7b49deeeb 100644 --- a/core/modules/migrate/tests/src/Unit/MigrateSourceTest.php +++ b/core/modules/migrate/tests/src/Unit/MigrateSourceTest.php @@ -139,10 +139,12 @@ public function testHighwaterTrackChangesIncompatible() { * Test that the source count is correct. */ public function testCount() { - + // Use the Apcu cache backend, which confirms that the cache API is being + // properly used. $container = new ContainerBuilder(); - $container->register('cache.migrate', 'Drupal\Core\Cache\NullBackend') - ->setArguments(['migrate']); + $cache_tags_checksum = $this->getMock('\Drupal\Core\Cache\CacheTagsChecksumInterface'); + $container->register('cache.migrate', 'Drupal\Core\Cache\ApcuBackend') + ->setArguments(['migrate', 'migrate', $cache_tags_checksum]); \Drupal::setContainer($container); // Test that the basic count works. -- GitLab