Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 297969

Use tagged iterator in plugin.cache_clearer instead of a lazy service

$
0
0

Problem/Motivation

  plugin.cache_clearer:
    class: Drupal\Core\Plugin\CachedDiscoveryClearer
    lazy: true

However the service is always instantiated and used directly so the lazy proxy is pointless:

\Drupal::service('plugin.cache_clearer')->clearCachedDefinitions();

Even worse, the service is not lazily instantiated anyway:

> $proxy = \Drupal::service('plugin.cache_clearer');
= Drupal\Core\ProxyClass\Plugin\CachedDiscoveryClearer {#8061}

> (new ReflectionProperty($proxy, 'service'))->getValue($proxy);
= Drupal\Core\Plugin\CachedDiscoveryClearer {#8062}

The $service property should not be set until a method is called on the actual service, but the addCachedDiscovery method calls configured in PluginManagerPass trigger the instantiation of the real service as soon as the proxy service is created.

Steps to reproduce

Proposed resolution

Remove the lazy proxy. Use a tagged iterator instead of calls to addCachedDiscovery.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet


Viewing all articles
Browse latest Browse all 297969

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>