Commit af1abd85 authored by alexpott's avatar alexpott

Issue #2780905 by catch, joelpittet: cache MemoryBackend has a pointless constructor

parent dd3ee4c7
......@@ -19,15 +19,6 @@ class MemoryBackend implements CacheBackendInterface, CacheTagsInvalidatorInterf
*/
protected $cache = array();
/**
* Constructs a MemoryBackend object.
*
* @param string $bin
* The cache bin for which the object is created.
*/
public function __construct($bin) {
}
/**
* {@inheritdoc}
*/
......
......@@ -16,7 +16,7 @@ class MemoryBackendFactory implements CacheFactoryInterface {
*/
function get($bin) {
if (!isset($this->bins[$bin])) {
$this->bins[$bin] = new MemoryBackend($bin);
$this->bins[$bin] = new MemoryBackend();
}
return $this->bins[$bin];
}
......
......@@ -101,12 +101,12 @@ class StorageComparer implements StorageComparerInterface {
public function __construct(StorageInterface $source_storage, StorageInterface $target_storage, ConfigManagerInterface $config_manager) {
// Wrap the storages in a static cache so that multiple reads of the same
// raw configuration object are not costly.
$this->sourceCacheStorage = new MemoryBackend(__CLASS__ . '::source');
$this->sourceCacheStorage = new MemoryBackend();
$this->sourceStorage = new CachedStorage(
$source_storage,
$this->sourceCacheStorage
);
$this->targetCacheStorage = new MemoryBackend(__CLASS__ . '::target');
$this->targetCacheStorage = new MemoryBackend();
$this->targetStorage = new CachedStorage(
$target_storage,
$this->targetCacheStorage
......
......@@ -35,7 +35,7 @@ protected function setUp() {
$this->installEntitySchema('file');
$entity_manager = \Drupal::entityManager();
$link_manager = new LinkManager(new TypeLinkManager(new MemoryBackend('default'), \Drupal::moduleHandler(), \Drupal::service('config.factory'), \Drupal::service('request_stack'), \Drupal::service('entity_type.bundle.info')), new RelationLinkManager(new MemoryBackend('default'), $entity_manager, \Drupal::moduleHandler(), \Drupal::service('config.factory'), \Drupal::service('request_stack')));
$link_manager = new LinkManager(new TypeLinkManager(new MemoryBackend(), \Drupal::moduleHandler(), \Drupal::service('config.factory'), \Drupal::service('request_stack'), \Drupal::service('entity_type.bundle.info')), new RelationLinkManager(new MemoryBackend(), $entity_manager, \Drupal::moduleHandler(), \Drupal::service('config.factory'), \Drupal::service('request_stack')));
// Set up the mock serializer.
$normalizers = array(
......
......@@ -131,7 +131,7 @@ protected function setUp() {
])->save();
$entity_manager = \Drupal::entityManager();
$link_manager = new LinkManager(new TypeLinkManager(new MemoryBackend('default'), \Drupal::moduleHandler(), \Drupal::service('config.factory'), \Drupal::service('request_stack'), \Drupal::service('entity_type.bundle.info')), new RelationLinkManager(new MemoryBackend('default'), $entity_manager, \Drupal::moduleHandler(), \Drupal::service('config.factory'), \Drupal::service('request_stack')));
$link_manager = new LinkManager(new TypeLinkManager(new MemoryBackend(), \Drupal::moduleHandler(), \Drupal::service('config.factory'), \Drupal::service('request_stack'), \Drupal::service('entity_type.bundle.info')), new RelationLinkManager(new MemoryBackend(), $entity_manager, \Drupal::moduleHandler(), \Drupal::service('config.factory'), \Drupal::service('request_stack')));
$chain_resolver = new ChainEntityResolver(array(new UuidResolver($entity_manager), new TargetIdResolver()));
......
......@@ -17,9 +17,9 @@ protected function createCacheBackend($bin) {
// We need to create some various backends in the chain.
$chain
->appendBackend(new MemoryBackend('foo'))
->prependBackend(new MemoryBackend('bar'))
->appendBackend(new MemoryBackend('baz'));
->appendBackend(new MemoryBackend())
->prependBackend(new MemoryBackend())
->appendBackend(new MemoryBackend());
\Drupal::service('cache_tags.invalidator')->addInvalidator($chain);
......
......@@ -18,7 +18,7 @@ class MemoryBackendTest extends GenericCacheBackendUnitTestBase {
* A new MemoryBackend object.
*/
protected function createCacheBackend($bin) {
$backend = new MemoryBackend($bin);
$backend = new MemoryBackend();
\Drupal::service('cache_tags.invalidator')->addInvalidator($backend);
return $backend;
}
......
......@@ -160,7 +160,7 @@ function testWhitelist() {
$connection = Database::getConnection();
$this->fixtures->createTables($connection);
$memoryCounterBackend = new MemoryCounterBackend('default');
$memoryCounterBackend = new MemoryCounterBackend();
// Create AliasManager and Path object.
$aliasStorage = new AliasStorage($connection, $this->container->get('module_handler'));
......
......@@ -42,7 +42,7 @@ protected function setUp() {
// as derivatives and ReflectionFactory.
$this->testPluginManager = new TestPluginManager();
$this->mockBlockManager = new MockBlockManager();
$module_handler = new ModuleHandler(\Drupal::root(), array(), new MemoryBackend('plugin'), $this->container->get('event_dispatcher'));
$module_handler = new ModuleHandler(\Drupal::root(), array(), new MemoryBackend(), $this->container->get('event_dispatcher'));
$this->defaultsTestPluginManager = new DefaultsTestPluginManager($module_handler);
// The expected plugin definitions within each manager. Several tests assert
......
......@@ -83,7 +83,7 @@ protected function setUp() {
$this->fixtures = new RoutingFixtures();
$this->state = new State(new KeyValueMemoryFactory());
$this->currentPath = new CurrentPathStack(new RequestStack());
$this->cache = new MemoryBackend('data');
$this->cache = new MemoryBackend();
$this->pathProcessor = \Drupal::service('path_processor_manager');
$this->cacheTagsInvalidator = \Drupal::service('cache_tags.invalidator');
}
......
......@@ -106,7 +106,7 @@ protected function setUp() {
$this->languageManager->expects($this->any())
->method('getCurrentLanguage')
->will($this->onConsecutiveCalls($english, $english, $japanese, $japanese));
$this->cache = new TestMemoryBackend('llama');
$this->cache = new TestMemoryBackend();
$this->assetResolver = new AssetResolver($this->libraryDiscovery, $this->libraryDependencyResolver, $this->moduleHandler, $this->themeManager, $this->languageManager, $this->cache);
}
......
......@@ -46,9 +46,9 @@ protected function setUp() {
parent::setUp();
// Set up three memory backends to be used in the chain.
$this->firstBackend = new MemoryBackend('foo');
$this->secondBackend = new MemoryBackend('bar');
$this->thirdBackend = new MemoryBackend('baz');
$this->firstBackend = new MemoryBackend();
$this->secondBackend = new MemoryBackend();
$this->thirdBackend = new MemoryBackend();
// Set an initial fixed dataset for all testing. The next three data
// collections will test two edge cases (last backend has the data, and
......
......@@ -62,7 +62,7 @@ public function testGetDoesntHitConsistentBackend() {
$consistent_cache->expects($this->never())
->method('getMultiple');
$fast_cache = new MemoryBackend('foo');
$fast_cache = new MemoryBackend();
$fast_cache->set('foo', 'baz');
$chained_fast_backend = new ChainedFastBackend(
......
......@@ -79,8 +79,8 @@ public function testContextBubblingCustomCacheBin() {
$bin = $this->randomMachineName();
$this->setUpRequest();
$this->memoryCache = new MemoryBackend('render');
$custom_cache = new MemoryBackend($bin);
$this->memoryCache = new MemoryBackend();
$custom_cache = new MemoryBackend();
$this->cacheFactory->expects($this->atLeastOnce())
->method('get')
......
......@@ -208,7 +208,7 @@ protected function setUpUnusedCache() {
* Sets up a memory-based render cache back-end.
*/
protected function setupMemoryCache() {
$this->memoryCache = $this->memoryCache ?: new MemoryBackend('render');
$this->memoryCache = $this->memoryCache ?: new MemoryBackend();
$this->cacheFactory->expects($this->atLeastOnce())
->method('get')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment