Loading core/modules/dblog/src/Controller/DbLogController.php +7 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -362,6 +363,12 @@ public function formatMessage($row) { } // 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); } } Loading core/modules/dblog/tests/src/Functional/DbLogTest.php +33 −1 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ use Drupal\Core\Link; use Drupal\Core\Url; use Drupal\dblog\Controller\DbLogController; use Drupal\error_test\Controller\ErrorTestController; use Drupal\Tests\BrowserTestBase; /** Loading @@ -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} Loading Loading @@ -793,4 +801,28 @@ public function testSameTimestampEntries() { $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
core/modules/dblog/src/Controller/DbLogController.php +7 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -362,6 +363,12 @@ public function formatMessage($row) { } // 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); } } Loading
core/modules/dblog/tests/src/Functional/DbLogTest.php +33 −1 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ use Drupal\Core\Link; use Drupal\Core\Url; use Drupal\dblog\Controller\DbLogController; use Drupal\error_test\Controller\ErrorTestController; use Drupal\Tests\BrowserTestBase; /** Loading @@ -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} Loading Loading @@ -793,4 +801,28 @@ public function testSameTimestampEntries() { $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">'); } }