Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
lightning_core
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
lightning_core
Commits
b85de9ac
Commit
b85de9ac
authored
5 years ago
by
Adam G-H
Browse files
Options
Downloads
Patches
Plain Diff
Make the updatedb pre-command hook clear plugin discovery caches only, rather than all caches.
parent
67c622e7
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
drush.services.yml
+1
-0
1 addition, 0 deletions
drush.services.yml
src/Commands/Hooks.php
+21
-6
21 additions, 6 deletions
src/Commands/Hooks.php
with
22 additions
and
6 deletions
drush.services.yml
+
1
−
0
View file @
b85de9ac
...
...
@@ -4,6 +4,7 @@ services:
arguments
:
-
'
@extension.list.profile'
-
'
%install_profile%'
-
'
@plugin.cache_clearer'
tags
:
-
{
name
:
drush.command
}
...
...
This diff is collapsed.
Click to expand it.
src/Commands/Hooks.php
+
21
−
6
View file @
b85de9ac
...
...
@@ -5,6 +5,7 @@ namespace Drupal\lightning_core\Commands;
use
Consolidation\AnnotatedCommand\CommandData
;
use
Consolidation\OutputFormatters\Options\FormatterOptions
;
use
Drupal\Core\Extension\ProfileExtensionList
;
use
Drupal\Core\Plugin\CachedDiscoveryClearerInterface
;
use
Drush\Commands\DrushCommands
;
use
Symfony\Component\Console\Event\ConsoleCommandEvent
;
...
...
@@ -27,6 +28,13 @@ class Hooks extends DrushCommands {
*/
private
$installProfile
;
/**
* The plugin cache clearer service.
*
* @var \Drupal\Core\Plugin\CachedDiscoveryClearerInterface
*/
private
$pluginCacheClearer
;
/**
* Hooks constructor.
*
...
...
@@ -34,25 +42,32 @@ class Hooks extends DrushCommands {
* The profile extension list service.
* @param string $install_profile
* The install_profile parameter.
* @param \Drupal\Core\Plugin\CachedDiscoveryClearerInterface $plugin_cache_clearer
* The plugin cache clearer service.
*/
public
function
__construct
(
ProfileExtensionList
$profile_list
,
$install_profile
)
{
public
function
__construct
(
ProfileExtensionList
$profile_list
,
$install_profile
,
CachedDiscoveryClearerInterface
$plugin_cache_clearer
)
{
$this
->
profileList
=
$profile_list
;
$this
->
installProfile
=
$install_profile
;
$this
->
pluginCacheClearer
=
$plugin_cache_clearer
;
}
/**
* Clears all caches before database updates begin.
* 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. Clearing all caches before updates begin ensures that
* the system always has the freshest and most accurate data to work with,
* which is especially helpful during major surgery like a database update.
* 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
*/
public
function
preUpdate
()
{
drupal_flush_all_cache
s
();
$this
->
pluginCacheClearer
->
clearCachedDefinition
s
();
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment