Issue #2930283 by Krzysztof Domański, geek.merlin aka axel.rutz, hiten2112, dagmar, plach, alexpott, dawehner: Error backtrace malformatted
parent
83e62065d0
commit
010c63bc66
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Drupal\dblog\Controller;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\Component\Utility\Xss;
|
||||
|
@ -362,6 +363,12 @@ class DbLogController extends ControllerBase {
|
|||
}
|
||||
// Message to translate with injected variables.
|
||||
else {
|
||||
// Ensure backtrace strings are properly formatted.
|
||||
if (isset($variables['@backtrace_string'])) {
|
||||
$variables['@backtrace_string'] = new FormattableMarkup(
|
||||
'<pre class="backtrace">@backtrace_string</pre>', $variables
|
||||
);
|
||||
}
|
||||
$message = $this->t(Xss::filterAdmin($row->message), $variables);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ use Drupal\Core\Logger\RfcLogLevel;
|
|||
use Drupal\Core\Link;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\dblog\Controller\DbLogController;
|
||||
use Drupal\error_test\Controller\ErrorTestController;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
|
@ -26,7 +27,14 @@ class DbLogTest extends BrowserTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['dblog', 'node', 'forum', 'help', 'block'];
|
||||
public static $modules = [
|
||||
'dblog',
|
||||
'error_test',
|
||||
'node',
|
||||
'forum',
|
||||
'help',
|
||||
'block',
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -793,4 +801,28 @@ class DbLogTest extends BrowserTestBase {
|
|||
$this->assertEquals($entries[2]['message'], 'First Entry #0');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that the details page displays correctly backtrace.
|
||||
*/
|
||||
public function testBacktrace() {
|
||||
$this->drupalLogin($this->adminUser);
|
||||
$this->drupalGet('/error-test/generate-warnings');
|
||||
|
||||
$wid = Database::getConnection()->query('SELECT MAX(wid) FROM {watchdog}')->fetchField();
|
||||
$this->drupalGet('admin/reports/dblog/event/' . $wid);
|
||||
|
||||
$error_user_notice = [
|
||||
'%type' => 'User warning',
|
||||
'@message' => 'Drupal & awesome',
|
||||
'%function' => ErrorTestController::class . '->generateWarnings()',
|
||||
'%file' => drupal_get_path('module', 'error_test') . '/error_test.module',
|
||||
];
|
||||
|
||||
// Check if the full message displays on the details page and backtrace is a
|
||||
// pre-formatted text.
|
||||
$message = new FormattableMarkup('%type: @message in %function (line', $error_user_notice);
|
||||
$this->assertRaw($message);
|
||||
$this->assertRaw('<pre class="backtrace">');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue