function _drupal_shutdown_function

Same name in other branches
  1. 7.x includes/bootstrap.inc \_drupal_shutdown_function()
  2. 9 core/includes/bootstrap.inc \_drupal_shutdown_function()
  3. 8.9.x core/includes/bootstrap.inc \_drupal_shutdown_function()
  4. 11.x core/includes/bootstrap.inc \_drupal_shutdown_function()

Executes registered shutdown functions.

1 call to _drupal_shutdown_function()
ShutdownFunctionTest::testShutdownFunctionInShutdownFunction in core/tests/Drupal/KernelTests/Core/Bootstrap/ShutdownFunctionTest.php
Tests that shutdown functions can be added by other shutdown functions.
1 string reference to '_drupal_shutdown_function'
drupal_register_shutdown_function in core/includes/bootstrap.inc
Registers a function for execution on shutdown.

File

core/includes/bootstrap.inc, line 535

Code

function _drupal_shutdown_function() {
    $callbacks =& drupal_register_shutdown_function();
    // Set the CWD to DRUPAL_ROOT as it is not guaranteed to be the same as it
    // was in the normal context of execution.
    chdir(DRUPAL_ROOT);
    try {
        reset($callbacks);
        // Do not use foreach() here because it is possible that the callback will
        // add to the $callbacks array via drupal_register_shutdown_function().
        while ($callback = current($callbacks)) {
            call_user_func_array($callback['callback'], $callback['arguments']);
            next($callbacks);
        }
    } catch (\Throwable $error) {
        _drupal_shutdown_function_handle_exception($error);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.