Loading core/lib/Drupal/Core/Logger/LogMessageParser.php +1 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ public function parseMessagePlaceholders(&$message, array &$context) { $has_psr3 = TRUE; // Transform PSR3 style messages containing placeholders to // \Drupal\Component\Render\FormattableMarkup style. $message = preg_replace('/\{(.*)\}/U', '@$1', $message); $message = preg_replace('/\{([^\{}]*)\}/U', '@$1', $message); } foreach ($context as $key => $variable) { // PSR3 style placeholders. Loading core/modules/dblog/tests/src/Functional/DbLogTest.php +17 −0 Original line number Diff line number Diff line Loading @@ -245,6 +245,23 @@ public function testLogEventPageWithMissingInfo() { $this->assertSession()->linkNotExists($request_uri); } /** * Test that twig errors are displayed correctly. */ public function testMessageParsing() { $this->drupalLogin($this->adminUser); // Log a common twig error with {{ }} and { } variables. \Drupal::service('logger.factory')->get("php") ->error('Incorrect parameter {{foo}} in path {path}: {value}', ['foo' => 'bar', 'path' => '/baz', 'value' => 'horse'] ); // View the log page to verify it's correct. $wid = \Drupal::database()->query('SELECT MAX(wid) FROM {watchdog}')->fetchField(); $this->drupalGet('admin/reports/dblog/event/' . $wid); $this->assertSession() ->responseContains('Incorrect parameter {bar} in path /baz: horse'); } /** * Verifies setting of the database log row limit. * Loading core/tests/Drupal/Tests/Core/Logger/LogMessageParserTest.php +2 −2 Original line number Diff line number Diff line Loading @@ -60,8 +60,8 @@ public function providerTestParseMessagePlaceholders() { ], // Message with double PSR3 style messages. [ ['message' => 'Test {with} two {encapsuled} strings', 'context' => ['with' => 'together', 'encapsuled' => 'awesome']], ['message' => 'Test @with two @encapsuled strings', 'context' => ['@with' => 'together', '@encapsuled' => 'awesome']], ['message' => 'Test {with} two {{encapsuled}} strings', 'context' => ['with' => 'together', 'encapsuled' => 'awesome']], ['message' => 'Test @with two {@encapsuled} strings', 'context' => ['@with' => 'together', '@encapsuled' => 'awesome']], ], ]; } Loading Loading
core/lib/Drupal/Core/Logger/LogMessageParser.php +1 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ public function parseMessagePlaceholders(&$message, array &$context) { $has_psr3 = TRUE; // Transform PSR3 style messages containing placeholders to // \Drupal\Component\Render\FormattableMarkup style. $message = preg_replace('/\{(.*)\}/U', '@$1', $message); $message = preg_replace('/\{([^\{}]*)\}/U', '@$1', $message); } foreach ($context as $key => $variable) { // PSR3 style placeholders. Loading
core/modules/dblog/tests/src/Functional/DbLogTest.php +17 −0 Original line number Diff line number Diff line Loading @@ -245,6 +245,23 @@ public function testLogEventPageWithMissingInfo() { $this->assertSession()->linkNotExists($request_uri); } /** * Test that twig errors are displayed correctly. */ public function testMessageParsing() { $this->drupalLogin($this->adminUser); // Log a common twig error with {{ }} and { } variables. \Drupal::service('logger.factory')->get("php") ->error('Incorrect parameter {{foo}} in path {path}: {value}', ['foo' => 'bar', 'path' => '/baz', 'value' => 'horse'] ); // View the log page to verify it's correct. $wid = \Drupal::database()->query('SELECT MAX(wid) FROM {watchdog}')->fetchField(); $this->drupalGet('admin/reports/dblog/event/' . $wid); $this->assertSession() ->responseContains('Incorrect parameter {bar} in path /baz: horse'); } /** * Verifies setting of the database log row limit. * Loading
core/tests/Drupal/Tests/Core/Logger/LogMessageParserTest.php +2 −2 Original line number Diff line number Diff line Loading @@ -60,8 +60,8 @@ public function providerTestParseMessagePlaceholders() { ], // Message with double PSR3 style messages. [ ['message' => 'Test {with} two {encapsuled} strings', 'context' => ['with' => 'together', 'encapsuled' => 'awesome']], ['message' => 'Test @with two @encapsuled strings', 'context' => ['@with' => 'together', '@encapsuled' => 'awesome']], ['message' => 'Test {with} two {{encapsuled}} strings', 'context' => ['with' => 'together', 'encapsuled' => 'awesome']], ['message' => 'Test @with two {@encapsuled} strings', 'context' => ['@with' => 'together', '@encapsuled' => 'awesome']], ], ]; } Loading