diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
index 8e2b3a7..6e7beed 100644
--- a/includes/bootstrap.inc
+++ b/includes/bootstrap.inc
@@ -1076,16 +1076,26 @@ function _drupal_get_filename_fallback_trigger_error($type, $name, $error_type)
static $errors_triggered = array();
if (empty($errors_triggered[$type][$name][$error_type])) {
if ($error_type == 'missing') {
- trigger_error(format_string('The following @type is missing from the file system: %name. In order to fix this, put the @type back in its original location. For more information, see the documentation page.', array('@type' => $type, '%name' => $name, '@documentation' => 'https://www.drupal.org/node/2487215')), E_USER_WARNING);
+ _drupal_trigger_error_with_delayed_logging(format_string('The following @type is missing from the file system: %name. In order to fix this, put the @type back in its original location. For more information, see the documentation page.', array('@type' => $type, '%name' => $name, '@documentation' => 'https://www.drupal.org/node/2487215')), E_USER_WARNING);
}
elseif ($error_type == 'moved') {
- trigger_error(format_string('The following @type has moved within the file system: %name. In order to fix this, clear caches or put the @type back in its original location. For more information, see the documentation page.', array('@type' => $type, '%name' => $name, '@documentation' => 'https://www.drupal.org/node/2487215')), E_USER_WARNING);
+ _drupal_trigger_error_with_delayed_logging(format_string('The following @type has moved within the file system: %name. In order to fix this, clear caches or put the @type back in its original location. For more information, see the documentation page.', array('@type' => $type, '%name' => $name, '@documentation' => 'https://www.drupal.org/node/2487215')), E_USER_WARNING);
}
$errors_triggered[$type][$name][$error_type] = TRUE;
}
}
/**
+ * @todo document this
+ */
+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;
+}
+
+/**
* Writes the file scan cache to the persistent cache.
*
* This cache stores all files marked as missing or moved after a file scan
diff --git a/includes/errors.inc b/includes/errors.inc
index a9b7b5b..8a876e1 100644
--- a/includes/errors.inc
+++ b/includes/errors.inc
@@ -199,7 +199,13 @@ function _drupal_log_error($error, $fatal = FALSE) {
$number++;
}
- watchdog('php', '%type: !message in %function (line %line of %file).', $error, $error['severity_level']);
+ // @todo document this
+ if ($fatal || !drupal_static('_drupal_trigger_error_with_delayed_logging')) {
+ watchdog('php', '%type: !message in %function (line %line of %file).', $error, $error['severity_level']);
+ }
+ else {
+ drupal_register_shutdown_function('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)');