Problem/Motivation
Since #3163002: Make late runtime processor compatible with drush , purge will call all active plugins on every KernelEvents::TERMINATE event. This breaks sites using the Config Split module to have different purgers on different environments.
Steps to reproduce
- Have a site with purge + purge_processor_lateruntime installed
- Using Config Split, enable a module the provides a different purger (for example Acquia Purge), only on environments where the split is active.
- Generate a DB with the 3 modules enabled (which would mimic the "prod" database)
- Locally (where the split that enables Acquia Purge is NOT active), import config with drush config:import, to disable the split and have only the lateruntime processor purger available.
Expected:
Config import happens as usual, the "Acquia Purge" split is disabled, and nothing breaks.
Actual:
Config import breaks with:
> > In Container.php line 156:
> >
> > You have requested a non-existent service "acquia_purge.platforminfo".
> >
> >
> > config:import [--preview [PREVIEW]] [--source SOURCE] [--partial] [--diff] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-d|--debug] [-y|--yes] [--no] [--remote-host REMOTE-HOST] [--remote-user REMOTE-USER] [-r|--root ROOT] [-l|--uri URI] [--simulate] [--pipe] [-D|--define DEFINE] [--quiet-abort [QUIET-ABORT]] [--druplicon] [--notify] [--xh-link XH-LINK] [--force-on-live] [--] <command> [<label>]
> >
> >
Fatal error: Uncaught LogicException: ::setPurgers() hasn't been called! in /var/lib/tugboat/docroot/modules/contrib/purge/src/Plugin/Purge/Purger/CapacityTracker.php:266
Stack trace:
#0 /var/lib/tugboat/docroot/modules/contrib/purge/src/Plugin/Purge/Queue/QueueService.php(145): Drupal\purge\Plugin\Purge\Purger\CapacityTracker->getRemainingInvalidationsLimit()
#1 /var/lib/tugboat/docroot/modules/contrib/purge/modules/purge_processor_lateruntime/src/EventSubscriber/LateRuntimeProcessor.php(87): Drupal\purge\Plugin\Purge\Queue\QueueService->claim()
#2 [internal function]: Drupal\purge_processor_lateruntime\EventSubscriber\LateRuntimeProcessor->onKernelTerminate(Object(Symfony\Component\HttpKernel\Event\TerminateEvent), 'kernel.terminat...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#3 /var/lib/tugboat/docroot/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(142): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\TerminateEvent), 'kernel.terminat...', Obj in /var/lib/tugboat/docroot/modules/contrib/purge/src/Plugin/Purge/Purger/CapacityTracker.php on line 266
Proposed resolution
My suggestion is to directly revert #3163002: Make late runtime processor compatible with drush
As stated in #3163002-8: Make late runtime processor compatible with drush and subsequent comments, the expectation for drush users is that a CLI execution would NOT trigger web-related events.
Comments
Comment #2
marcoscanoComment #3
rp7 commentedI can't comment on whether the Purge module or the Config Split module is in the wrong here, but I believe the proposed resolution is incorrect or badly formulated at the least.
It makes it sound like the Purge module (and more explicitly the change in #3163002: Make late runtime processor compatible with drush) is causing CLI commands to trigger the
KernelEvents::TERMINATEevent, but that's not the case. Reverting the change in #3163002: Make late runtime processor compatible with drush will not prevent that from happening.AFAICT this is works as designed in Drush since https://github.com/drush-ops/drush/issues/1252 landed. If it's this that really needs to be changed, than a ticket in Drush issues queue should be created.
Comment #4
marcoscanoSorry for the badly worded initial description. (you can see I tried to improve it in #2 :) )
What I meant is that when
KernelEvents::TERMINATEis dispatched, now purge calls$this->initialize()on the above-mentioned purger, which will call all active plugins from config, and it will break if the config in DB is not in sync with the codebase (which happens, for example, during thedrush config:importcommand).Prior to #3163002: Make late runtime processor compatible with drush, the
$this->initialize()call was being made onKernelEvents::FINISH_REQUESTevents, which aren't triggered bydrush config:importHope it's clearer now! Thanks!
Comment #5
reszliIndeed, we ran into the following errors after updating when running config import:
You have requested a non-existent service "custom_purge.default".[error] diagnostics: ERROR: Purgers: There is no purger loaded which means that you need a module enabled to provide a purger plugin to clear your external cache or CDN.second (or third) config import actually fixes it, but it's not ideal