public function Hooks::preUpdate in Lightning Core 8.5
Same name and namespace in other branches
- 8.2 src/Commands/Hooks.php \Drupal\lightning_core\Commands\Hooks::preUpdate()
- 8.3 src/Commands/Hooks.php \Drupal\lightning_core\Commands\Hooks::preUpdate()
- 8.4 src/Commands/Hooks.php \Drupal\lightning_core\Commands\Hooks::preUpdate()
Clears all plugin caches before database updates begin.
A common cause of errors during database updates is update hooks inadvertently using stale data from the myriad caches in Drupal core and contributed modules. To migitate this, we do a bit of cache pruning before database updates begin.
drupal_flush_all_caches() is extremely aggressive because it rebuilds the router and other things, but it's a bit too much of a sledgehammer for our purposes. A good compromise is to clear all plugin discovery caches (which will include entity type definitions).
@hook pre-command updatedb
File
- src/
Commands/ Hooks.php, line 69
Class
- Hooks
- Implements Drush command hooks.
Namespace
Drupal\lightning_core\CommandsCode
public function preUpdate() {
$this->pluginCacheClearer
->clearCachedDefinitions();
}