function _drupal_log_error

cis7 _drupal_log_error($error, $fatal = FALSE)
cle7 _drupal_log_error($error, $fatal = FALSE)
elmsmedia7 _drupal_log_error($error, $fatal = FALSE)
icor7 _drupal_log_error($error, $fatal = FALSE)
meedjum_blog7 _drupal_log_error($error, $fatal = FALSE)
mooc7 _drupal_log_error($error, $fatal = FALSE)

Logs a PHP error or exception and displays an error page in fatal cases.


$error: An array with the following keys: %type, !message, %function, %file, %line and severity_level. All the parameters are plain-text, with the exception of !message, which needs to be a safe HTML string.

$fatal: TRUE if the error is fatal.

3 calls to _drupal_log_error()
backtrace_error_handler in sites/all/modules/ulmus/devel/devel.module
Displays backtrace showing the route of calls to the current error.
_drupal_error_handler_real in includes/
Provides custom PHP error handling.
_drupal_exception_handler in includes/
Provides custom PHP exception handling.


includes/, line 171
Functions for error handling.


function _drupal_log_error($error, $fatal = FALSE) {
  // Initialize a maintenance theme if the bootstrap was not complete.
  // Do it early because drupal_set_message() triggers a drupal_theme_initialize().
  if ($fatal && (drupal_get_bootstrap_phase() != DRUPAL_BOOTSTRAP_FULL)) {
    if (!defined('MAINTENANCE_MODE')) {
      define('MAINTENANCE_MODE', 'error');

  // When running inside the testing framework, we relay the errors
  // to the tested site by the way of HTTP headers.
  $test_info = &$GLOBALS['drupal_test_info'];
  if (!empty($test_info['in_child_site']) && !headers_sent() && (!defined('SIMPLETEST_COLLECT_ERRORS') || SIMPLETEST_COLLECT_ERRORS)) {
    // $number does not use drupal_static as it should not be reset
    // as it uniquely identifies each PHP error.
    static $number = 0;
    $assertion = array(
        'function' => $error['%function'],
        'file' => $error['%file'],
        'line' => $error['%line'],
    header('X-Drupal-Assertion-' . $number . ': ' . rawurlencode(serialize($assertion)));

  watchdog('php', '%type: !message in %function (line %line of %file).', $error, $error['severity_level']);

  if ($fatal) {
    drupal_add_http_header('Status', '500 Service unavailable (with message)');

  if (drupal_is_cli()) {
    if ($fatal) {
      // When called from CLI, simply output a plain text message.
      print html_entity_decode(strip_tags(t('%type: !message in %function (line %line of %file).', $error))) . "\n";

  if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
    if ($fatal) {
      if (error_displayable($error)) {
        // When called from JavaScript, simply output the error message.
        print t('%type: !message in %function (line %line of %file).', $error);
  else {
    // Display the message if the current error reporting level allows this type
    // of message to be displayed, and unconditionnaly in update.php.
    if (error_displayable($error)) {
      $class = 'error';

      // If error type is 'User notice' then treat it as debug information
      // instead of an error message, see dd().
      if ($error['%type'] == 'User notice') {
        $error['%type'] = 'Debug';
        $class = 'status';

      drupal_set_message(t('%type: !message in %function (line %line of %file).', $error), $class);

    if ($fatal) {
      // We fallback to a maintenance page at this point, because the page generation
      // itself can generate errors.
      print theme('maintenance_page', array('content' => t('The website encountered an unexpected error. Please try again later.')));



Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/ in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/
The website encountered an unexpected error. Please try again later.