Problem/Motivation
RequestCloseSubscriber has a curious comment and does exactly one thing on kernel terminate:
/**
* Performs end of request tasks.
*
* @todo The body of this function has just been copied almost verbatim from
* drupal_page_footer(). There's probably a lot in here that needs to get
* removed/changed. Also, if possible, do more light-weight shutdowns on
* AJAX requests.
*
* @param \Symfony\Component\HttpKernel\Event\TerminateEvent $event
* The Event to process.
*/
public function onTerminate(TerminateEvent $event) {
$this->moduleHandler->writeCache();
}
Steps to reproduce
Proposed resolution
Move writeCache() to a destruct() method in ModuleHandler.
Tag ModuleHandler for needs_destruction.
Delete RequestCloseSubscriber.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Issue fork drupal-3436599
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3436599-replace-requestclosesubscriber-with
changes, plain diff MR !7216
Comments
Comment #2
longwaveThis event subscriber has slowly been chipped away at over the years:
#1698108: Update Drupal's dependencies
#1541674: Remove the registry
#1269742: Make path lookup code into a pluggable class
#1331486: Move module_invoke_*() and friends to an Extensions class
#1911178: Remove hook_exit()
#2220687: Convert system_run_automated_cron into a subscriber for KernelEvents::TERMINATE
#2231419: Merge obsolete CachedModuleHandler into ModuleHandler
Time to finally retire it?
Comment #4
spokjeMakes sense to me, and tests are green => RTBC
Comment #5
alexpottAs per https://www.drupal.org/about/core/policies/core-change-policies/bc-polic... event subscribers are not part of the API so we can remove this class without a deprecation.
One thing I wonder is how will this cache be written if doing some event loop type thing with Drupal.
Comment #6
longwaveDoes that make any difference here?
DrupalKernel::terminate():KernelEvents::TERMINATEis fired duringHttpKernel::terminate(), we've just moved the subscribed method down to the destruction loop instead.Comment #7
alexpottGood point. 1 less service FTW!
Committed and pushed 4a26ee1f81 to 11.x and 2505f212bf to 10.3.x. Thanks!
Comment #10
alexpottI did check contrib... i think there are no issues with removing the class - https://git.drupalcode.org/search?group_id=2&repository_ref=&scope=blobs...
Comment #13
eduardo morales albertiAfter deploy the last version of Drupal 10.3.5 we got the following error:
Could it be related to any cache type?