function drupal_register_shutdown_function in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/includes/bootstrap.inc \drupal_register_shutdown_function()
Registers a function for execution on shutdown.
Wrapper for register_shutdown_function() that catches thrown exceptions to avoid "Exception thrown without a stack frame in Unknown".
Parameters
$callback: The shutdown function to register.
...: Additional arguments to pass to the shutdown function.
Return value
Array of shutdown functions to be executed.
See also
Related topics
10 calls to drupal_register_shutdown_function()
- DatabaseLockBackend::__construct in core/
lib/ Drupal/ Core/ Lock/ DatabaseLockBackend.php - Constructs a new DatabaseLockBackend.
- KernelTestBase::assertPostConditions in core/
tests/ Drupal/ KernelTests/ KernelTestBase.php - MemcacheLockBackend::__construct in modules/
memcache/ src/ MemcacheLockBackend.php - Constructs a new MemcacheLockBackend.
- search_cron in core/
modules/ search/ search.module - Implements hook_cron().
- SystemTestController::shutdownFunctions in core/
modules/ system/ tests/ modules/ system_test/ src/ Controller/ SystemTestController.php - A simple page callback which adds a register shutdown function.
File
- core/
includes/ bootstrap.inc, line 944 - Functions that need to be loaded on every Drupal request.
Code
function &drupal_register_shutdown_function($callback = NULL) {
// We cannot use drupal_static() here because the static cache is reset during
// batch processing, which breaks batch handling.
static $callbacks = array();
if (isset($callback)) {
// Only register the internal shutdown function once.
if (empty($callbacks)) {
register_shutdown_function('_drupal_shutdown_function');
}
$args = func_get_args();
// Remove $callback from the arguments.
unset($args[0]);
// Save callback and arguments
$callbacks[] = array(
'callback' => $callback,
'arguments' => $args,
);
}
return $callbacks;
}