function _drupal_trigger_error_with_delayed_logging

_drupal_trigger_error_with_delayed_logging($error_msg, $error_type = E_USER_NOTICE)

Invokes trigger_error() with logging delayed until the end of the request.

This is an alternative to PHP's trigger_error() function which can be used during low-level Drupal core operations that need to avoid being interrupted by a watchdog() call.

Normally, Drupal's error handler calls watchdog() in response to a trigger_error() call. However, this invokes hook_watchdog() which can run arbitrary code. If the trigger_error() happens in the middle of an operation such as a rebuild operation which should not be interrupted by arbitrary code, that could potentially break or trigger the rebuild again. This function protects against that by delaying the watchdog() call until the end of the current page request.

This is an internal function which should only be called by low-level Drupal core functions. It may be removed in a future Drupal 7 release.

Parameters

string $error_msg: The error message to trigger. As with trigger_error() itself, this is limited to 1024 bytes; additional characters beyond that will be removed.

int $error_type: (optional) The type of error. This should be one of the E_USER family of constants. As with trigger_error() itself, this defaults to E_USER_NOTICE if not provided.

See also

_drupal_log_error()

File

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

Code

function _drupal_trigger_error_with_delayed_logging($error_msg, $error_type = E_USER_NOTICE) {
  $delay_logging = &drupal_static(__FUNCTION__, FALSE);
  $delay_logging = TRUE;
  trigger_error($error_msg, $error_type);
  $delay_logging = FALSE;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/includes!bootstrap.inc/function/_drupal_trigger_error_with_delayed_logging/7.x