Download & Extend

hook_exit() has been removed

Project: 
Drupal core
Introduced in branch: 
8.x
Description: 

In Drupal 7, hook_exit would fire at the end of all requests, even "bootstrap only" requests, to allow modules to take action after a response has been generated but before the PHP process terminates. In Drupal 8, it has been removed as redundant.

Its most direct equivalent in Drupal 8 is the kernel.terminate event. Modules may implement a subscriber for that event to perform actions such as logging and cleanup that happen after the response has been sent to the client and the connection closed, but before the PHP process terminates. The kernel.terminate event will fire on every request, so be careful to avoid excessively expensive operations if possible.

Note that some uses of hook_exit() in Drupal 7 and contrib were not fully appropriate. A hook_exit() implementation that was (incorrectly) generating output, for instance, should likely instead be converted to a kernel.response event. Before converting a hook_exit() implementation, verify that it is appropriate for the event it is being converted into or that there is not some other approach that is more appropriate. See the discussion in #1911178: Remove hook_exit() about the overlay module for an example of how some uses may not map directly to kernel.terminate.

Impacts: 
Module developers
Updates Done (doc team, etc.)
Online documentation: 
Not done
Theming guide: 
Not done
Module developer documentation: 
Not done
Examples project: 
Not done
Coder Review: 
Not done
Coder Upgrade: 
Not done
Other: 
Other updates done