_drupal_shutdown_function

_drupal_shutdown_function()

Executes registered shutdown functions.

File

core/includes/bootstrap.inc, line 978
Functions that need to be loaded on every Drupal request.

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 {
    while (list($key, $callback) = each($callbacks)) {
      call_user_func_array($callback['callback'], $callback['arguments']);
    }
  }
  // PHP 7 introduces Throwable, which covers both Error and
  // Exception throwables.
  catch (\Throwable $error) {
    _drupal_shutdown_function_handle_exception($error);
  }
  // In order to be compatible with PHP 5 we also catch regular Exceptions.
  catch (\Exception $exception) {
    _drupal_shutdown_function_handle_exception($exception);
  }
}
doc_Drupal
2016-10-29 09:57:11
Comments
Leave a Comment

Please login to continue.