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

drupal_rebuild() doesn't account for PhpStorageFactory's pluggability

$
0
0

PhpStorageFactory allows you to override the storage class that's used in settings:

  public static function get($name) {
    $configuration = [];
    $overrides = Settings::get('php_storage');
    if (isset($overrides[$name])) {
      $configuration = $overrides[$name];
    }
    elseif (isset($overrides['default'])) {
      $configuration = $overrides['default'];
    }

That means that in your settings.php you can do this for instance:

$settings['php_storage'] = [
  'twig' => [
    'class' => 'my\custom\PhpStorage',
  ],
];

(Not that this is documented, BTW!!!)

However, drupal_rebuild(), which is documented as being usable when Drupal itself doesn't work ("Rebuilds all caches even when Drupal itself does not work."), calls the storage:

function drupal_rebuild($class_loader, Request $request) {
[SNIP]
  // Force kernel to rebuild php cache.
  PhpStorageFactory::get('twig')->deleteAll();

This means that if you specify a PHP storage class that is within a custom module, it's not available at this point.

So for instance, 'drush cr' will crash.

It's possible that this overriding functionality in PhpStorageFactory is intended only for the purpose of Drupal core's own testing, in which case, that should be clearly documented in the code so developers don't waste time trying to use it.


Viewing all articles
Browse latest Browse all 292339

Trending Articles



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