Issue #2492429 by mikeryan: Migration count caching broken

8.0.x
Alex Pott 2015-07-24 16:24:12 +01:00
parent c78f1dacee
commit c523c99567
2 changed files with 7 additions and 5 deletions

View File

@ -423,7 +423,7 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter
// 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 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter
// 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;

View File

@ -139,10 +139,12 @@ class MigrateSourceTest extends MigrateTestCase {
* 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.