Skip to content
Snippets Groups Projects
Unverified Commit f52c5af6 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2930283 by Krzysztof Domański, geek.merlin aka axel.rutz, hiten2112,...

Issue #2930283 by Krzysztof Domański, geek.merlin aka axel.rutz, hiten2112, dagmar, plach, alexpott, dawehner: Error backtrace malformatted

(cherry picked from commit 010c63bc)
parent af807602
No related branches found
No related tags found
9 merge requests!1445Issue #2920039: Views' User Name exposed group filter validation,!1298Issue #3240993: Let layout builder render inline block translations,!774Issue #3174569: Example node template file name is incorrect,!497Issue #2463967: Use .user.ini file for PHP settings,!433Resolve #3163663 "Too many open files",!233Resolve #2693787 "Taxonomy term name",!133Resolve #2666286 "Clean up menuui",!112Resolve #3187004 "Drupaldatetime serialization issue",!53Resolve #3181870: Correct typo "the the" in "core/classList" deprecation message.
......@@ -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 @@ 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);
}
}
......
......@@ -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;
/**
......@@ -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 @@ 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">');
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment