2c2
< index b3382bf..b4f56e7 100644
---
> index c06055e..50656c0 100644
5c5
< @@ -41,6 +41,56 @@ define('ERROR_REPORTING_DISPLAY_SOME', 1);
---
> @@ -41,6 +41,63 @@ define('ERROR_REPORTING_DISPLAY_SOME', 1);
14c14,15
< + * Error reporting type of debug information: Add backtrace information to messages on page.
---
> + * Error reporting type of debug information: Add backtrace information to
> + * messages on page.
29c30,31
< + * Error reporting type of debug information: How may calls deep from the error line to show scalar variables
---
> + * Error reporting type of debug information: How may calls deep from the error
> + * line to show scalar variables
34c36,37
< + * Error reporting type of debug information: How may calls deep from the error line to show scalar variables
---
> + * Error reporting type of debug information: How may calls deep from the error
> + * line to show scalar variables
39c42,43
< + * Error reporting type of debug information: How may calls deep from the error line to show non-scalar variables
---
> + * Error reporting type of debug information: How may calls deep from the error
> + * line to show non-scalar variables
44c48,49
< + * Error reporting type of debug information: How may calls deep from the error line to show non-scalar variables
---
> + * Error reporting type of debug information: How may calls deep from the error
> + * line to show non-scalar variables
49c54,55
< + * Error reporting type of debug information: How Non-scalar values can become too long to practically display. Limit the output size with this setting.
---
> + * Error reporting type of debug information: How Non-scalar values can become
> + * too long to practically display. Limit the output size with this setting.
54c60,61
< + * Error reporting type of debug information: How Non-scalar values can become too long to practically display. Limit the output size with this setting.
---
> + * Error reporting type of debug information: How Non-scalar values can become
> + * too long to practically display. Limit the output size with this setting.
62c69
< @@ -2300,6 +2363,30 @@ function drupal_get_hash_salt() {
---
> @@ -2572,6 +2629,30 @@ function drupal_get_hash_salt() {
94c101
< index a9b7b5b..4d82eef 100644
---
> index 3548d1f..d2ef2ed 100644
119d125
< - '%type' => get_class($exception),
121c127
< + '%type' => get_class($exception),
---
> '%type' => get_class($exception),
123c129
< // is plain-text. We mimick this behavior here.
---
> // is plain-text. We mimic this behavior here.
162,163c168,169
< @@ -199,7 +210,22 @@ function _drupal_log_error($error, $fatal = FALSE) {
< $number++;
---
> @@ -207,7 +218,22 @@ function _drupal_log_error($error, $fatal = FALSE) {
> drupal_register_shutdown_function('watchdog', 'php', '%type: !message in %function (line %line of %file).', $error, $error['severity_level']);
165,170c171,176
<
< - watchdog('php', '%type: !message in %function (line %line of %file).', $error, $error['severity_level']);
< + $st_opts = variable_get('error_backtrace_display', array(2 => 0, 1 => 0));
< + if (array_sum($st_opts)) {
< + $error['!backtrace'] = format_backtrace($backtrace);
< + }
---
> else {
> - watchdog('php', '%type: !message in %function (line %line of %file).', $error, $error['severity_level']);
> + $st_opts = variable_get('error_backtrace_display', array(2 => 0, 1 => 0));
> + if (array_sum($st_opts)) {
> + $error['!backtrace'] = format_backtrace($backtrace);
> + }
172,173d177
< + if ($st_opts[ERROR_REPORTING_DISPLAY_LOGS]) {
< + $message_line='%type:
!message
LINE: %line
FUNCTION: %function
FILE: %file';
175c179,184
< + $message_line .= ' !backtrace';
---
> + $message_line='%type: !message
LINE: %line
FUNCTION: %function
FILE: %file';
> + if ($st_opts[ERROR_REPORTING_DISPLAY_LOGS]) {
> + $message_line .= ' !backtrace';
> + }
> + } else {
> + $message_line='%type: !message in %function (line %line of %file).';
177,182c186,189
< + } else {
< + $message_line='%type: !message in %function (line %line of %file).';
< + }
< + if (!array_has_PDOException($error)) { // If it was a DB error don't write to the DB.
< + watchdog('php', $message_line, $error, $error['severity_level']);
< + }
---
> + if (!array_has_PDOException($error)) { // If it was a DB error don't write to the DB.
> + watchdog('php', $message_line, $error, $error['severity_level']);
> + }
> }
185,186c192
< drupal_add_http_header('Status', '500 Service unavailable (with message)');
< @@ -235,7 +261,23 @@ function _drupal_log_error($error, $fatal = FALSE) {
---
> @@ -244,7 +270,23 @@ function _drupal_log_error($error, $fatal = FALSE) {
211,217c217
< @@ -252,12 +294,12 @@ function _drupal_log_error($error, $fatal = FALSE) {
< * Gets the last caller from a backtrace.
< *
< * @param $backtrace
< - * A standard PHP backtrace.
< + * A standard PHP backtrace. Passed by reference.
< *
---
> @@ -266,7 +308,7 @@ function _drupal_log_error($error, $fatal = FALSE) {
226c226
< @@ -284,3 +326,158 @@ function _drupal_get_last_caller($backtrace) {
---
> @@ -293,3 +335,198 @@ function _drupal_get_last_caller($backtrace) {
247c247
< + // TODO: Styling should be in CSS or should make use of drupal's existing CSS.
---
> + add_backtrace_styling();
250,255d249
< +
369a364,381
> +/**
> + * Formats variables for better presentation.
> + *
> + * Formatting includes:
> + * Puts the type of variable in front of the value, e.g.
> + * "string: The quick brown..."
> + * Limits the length of string being returned.
> + * Optionally shows the number of characters truncated.
> + * Makes HTML safe.
> + *
> + * @param string $arg
> + * The variable to format as a string.
> + * @param int $max_len
> + * A limit on the length of string being returned.
> + * @param string $type
> + * The type of variable the string represents.
> + * @return string
> + */
384a397,425
> +
> +/**
> + * Adds some styling to make the display of the backtrace far clearer to analyze
> + *
> + * @staticvar boolean $needs_styling
> + */
> +function add_backtrace_styling() {
> + static $needs_styling = TRUE;
> +
> + if ($needs_styling) {
> + $css = << + .backtrace td, .backtrace th {
> + padding: 0 0.5em;
> + }
> + .backtrace .row-bunch {
> + border-top: 1px solid;
> + }
> + .backtrace .var-cell {
> + border: 1px dotted; width: 30%;
> + };
> + pre.backtrace {
> + font-family: "Andale Mono","Courier New",Courier,Lucidatypewriter,Fixed,monospace;
> + }
> +EOT;
> + drupal_add_css($css, array('type' => 'inline', 'preprocess' => FALSE));
> + $needs_styling = FALSE;
> + }
> +}
> \ No newline at end of file
386c427
< index 35a73c3..4d5de64 100644
---
> index 2167db7..0170a4f 100644
389c430
< @@ -974,6 +974,8 @@ function update_do_one($module, $number, $dependency_map, &$context) {
---
> @@ -982,6 +982,8 @@ function update_do_one($module, $number, $dependency_map, &$context) {
397a439,450
> diff --git a/modules/dblog/dblog.admin.inc b/modules/dblog/dblog.admin.inc
> index f8a00c2..e82fcb7 100644
> --- a/modules/dblog/dblog.admin.inc
> +++ b/modules/dblog/dblog.admin.inc
> @@ -153,6 +153,7 @@ function dblog_event($id) {
> $severity = watchdog_severity_levels();
> $result = db_query('SELECT w.*, u.name, u.uid FROM {watchdog} w INNER JOIN {users} u ON w.uid = u.uid WHERE w.wid = :id', array(':id' => $id))->fetchObject();
> if ($dblog = $result) {
> + add_backtrace_styling();
> $rows = array(
> array(
> array('data' => t('Type'), 'header' => TRUE),
399c452
< index 9183eed..df95582 100644
---
> index df305a2..02efbdf 100644
402,453c455,492
< @@ -144,20 +144,42 @@ function _dblog_get_message_types() {
< * Note: Some values may be truncated to meet database column size restrictions.
< */
< function dblog_watchdog(array $log_entry) {
< - Database::getConnection('default', 'default')->insert('watchdog')
< - ->fields(array(
< - 'uid' => $log_entry['uid'],
< - 'type' => substr($log_entry['type'], 0, 64),
< - 'message' => $log_entry['message'],
< - 'variables' => serialize($log_entry['variables']),
< - 'severity' => $log_entry['severity'],
< - 'link' => substr($log_entry['link'], 0, 255),
< - 'location' => $log_entry['request_uri'],
< - 'referer' => $log_entry['referer'],
< - 'hostname' => substr($log_entry['ip'], 0, 128),
< - 'timestamp' => $log_entry['timestamp'],
< - ))
< - ->execute();
< + if (!array_has_PDOException($log_entry)) { // If it was a DB error don't write to the DB.
< + Database::getConnection('default', 'default')->insert('watchdog')
< + ->fields(array(
< + 'uid' => $log_entry['uid'],
< + 'type' => substr($log_entry['type'], 0, 64),
< + 'message' => $log_entry['message'],
< + 'variables' => serialize($log_entry['variables']),
< + 'severity' => $log_entry['severity'],
< + 'link' => substr($log_entry['link'], 0, 255),
< + 'location' => $log_entry['request_uri'],
< + 'referer' => $log_entry['referer'],
< + 'hostname' => substr($log_entry['ip'], 0, 128),
< + 'timestamp' => $log_entry['timestamp'],
< + ))
< + ->execute();
< + }
< + else {
< + // The following if statement is because the test "basic upgrade path" throws
< + // the following error:
< + // SQLSTATE[42S02]: Base table or view not found: 1146
< + // Table 'drupal_7_dev.simpletest107742access' doesn't exist: SELECT mask
< + // FROM {access} WHERE status = :status AND type = :type;
< + // Array ( [:status] => 0 [:type] => host )
< + // however the existing Drupal error logging just let's it go without telling
< + // simpletests there's a problem (because a calling function uses a simple
< + // semaphore to stop errors being triggered inside the error handler). Since
< + // we go out of our way to catch these errors as well we won't pass the
< + // automatic tester while this error exists.
< + //
< + // To solve this we add the following if statement to more accurrately
< + // simulate Drupal's current behavior. Once the SQL error in the test is
< + // fixed we should remove this if statement.
< + if (!drupal_valid_test_ua()) {
< + _drupal_log_error($log_entry['variables'], TRUE);
---
> @@ -148,20 +148,47 @@ function dblog_watchdog(array $log_entry) {
> require_once DRUPAL_ROOT . '/includes/unicode.inc';
> }
> try {
> - Database::getConnection('default', 'default')->insert('watchdog')
> - ->fields(array(
> - 'uid' => $log_entry['uid'],
> - 'type' => drupal_substr($log_entry['type'], 0, 64),
> - 'message' => $log_entry['message'],
> - 'variables' => serialize($log_entry['variables']),
> - 'severity' => $log_entry['severity'],
> - 'link' => drupal_substr($log_entry['link'], 0, 255),
> - 'location' => $log_entry['request_uri'],
> - 'referer' => $log_entry['referer'],
> - 'hostname' => drupal_substr($log_entry['ip'], 0, 128),
> - 'timestamp' => $log_entry['timestamp'],
> - ))
> - ->execute();
> + // If it was a DB error don't write to the DB.
> + if (!array_has_PDOException($log_entry)) {
> + Database::getConnection('default', 'default')->insert('watchdog')
> + ->fields(array(
> + 'uid' => $log_entry['uid'],
> + 'type' => substr($log_entry['type'], 0, 64),
> + 'message' => $log_entry['message'],
> + 'variables' => serialize($log_entry['variables']),
> + 'severity' => $log_entry['severity'],
> + // Do not use substr() on link as it can split a UTF-8 character
> + // making the string an invalid multibyte string and the record will
> + // likely be rejected by the database. E.g., the $link variable in
> + // DrupalWebTestCase->generateLogEntries().
> + 'link' => mb_strimwidth($log_entry['link'], 0, 255),
> + 'location' => $log_entry['request_uri'],
> + 'referer' => $log_entry['referer'],
> + 'hostname' => substr($log_entry['ip'], 0, 128),
> + 'timestamp' => $log_entry['timestamp'],
> + ))
> + ->execute();
455,458c494,516
< + }
< }
<
< /**
---
> + else {
> + // The following if statement is because the test "basic upgrade path"
> + // throws the following error:
> + // SQLSTATE[42S02]: Base table or view not found: 1146
> + // Table 'drupal_7_dev.simpletest107742access' doesn't exist: SELECT
> + // mask FROM {access} WHERE status = :status AND type = :type;
> + // Array ( [:status] => 0 [:type] => host )
> + // however the existing Drupal error logging just let's it go without
> + // telling simpletests there's a problem (because a calling function uses
> + // a simple semaphore to stop errors being triggered inside the error
> + // handler). Since we go out of our way to catch these errors as well we
> + // won't pass the automatic tester while this error exists.
> + //
> + // To solve this we add the following if statement to more accurrately
> + // simulate Drupal's current behavior. Once the SQL error in the test is
> + // fixed we should remove this if statement.
> + if (!drupal_valid_test_ua()) {
> + _drupal_log_error($log_entry['variables'], TRUE);
> + }
> + }
> }
> catch (Exception $e) {
> // Exception is ignored so that watchdog does not break pages during the
460c518
< index 0f525c6..ecd3d98 100644
---
> index cdcc78f..ec8546b 100644
463c521
< @@ -1676,6 +1676,98 @@ function system_logging_settings() {
---
> @@ -1676,6 +1676,105 @@ function system_logging_settings() {
468a527,528
> + '#collapsible' => TRUE,
> + '#collapsed' => TRUE,
469a530
> + '#description' => t('These options should only be used in developer environments.'),
484a546,547
> + '#collapsible' => TRUE,
> + '#collapsed' => TRUE,
522a586,587
> + '#collapsible' => TRUE,
> + '#collapsed' => TRUE,
538c603
< + '#description' => t('From what depth to start showing scalar variables. 1 = the place the error occured.'),
---
> + '#description' => t('From what depth to start showing non-scalar variables. 1 = the place the error occured.'),