core/modules/big_pipe/src/Render/BigPipe.php | 4 ++++ core/modules/big_pipe/src/Tests/BigPipeTest.php | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/core/modules/big_pipe/src/Render/BigPipe.php b/core/modules/big_pipe/src/Render/BigPipe.php index 003822a..967a8ce 100644 --- a/core/modules/big_pipe/src/Render/BigPipe.php +++ b/core/modules/big_pipe/src/Render/BigPipe.php @@ -252,6 +252,7 @@ protected function sendNoJsPlaceholders($html, $no_js_placeholders, AttachedAsse throw $e; } else { + trigger_error($e, E_USER_ERROR); continue; } } @@ -288,6 +289,7 @@ protected function sendNoJsPlaceholders($html, $no_js_placeholders, AttachedAsse throw $e; } else { + trigger_error($e, E_USER_ERROR); continue; } } @@ -362,6 +364,7 @@ protected function sendPlaceholders(array $placeholders, array $placeholder_orde throw $e; } else { + trigger_error($e, E_USER_ERROR); continue; } } @@ -394,6 +397,7 @@ protected function sendPlaceholders(array $placeholders, array $placeholder_orde throw $e; } else { + trigger_error($e, E_USER_ERROR); continue; } } diff --git a/core/modules/big_pipe/src/Tests/BigPipeTest.php b/core/modules/big_pipe/src/Tests/BigPipeTest.php index 1b43663..26025a5 100644 --- a/core/modules/big_pipe/src/Tests/BigPipeTest.php +++ b/core/modules/big_pipe/src/Tests/BigPipeTest.php @@ -11,6 +11,7 @@ use Drupal\big_pipe\Render\BigPipe; use Drupal\Component\Serialization\Json; use Drupal\Component\Utility\Html; +use Drupal\Core\Logger\RfcLogLevel; use Drupal\Core\Url; use Drupal\simpletest\WebTestBase; @@ -32,7 +33,7 @@ class BigPipeTest extends WebTestBase { * * @var array */ - public static $modules = ['big_pipe', 'big_pipe_test']; + public static $modules = ['big_pipe', 'big_pipe_test', 'dblog']; /** * {@inheritdoc} @@ -152,6 +153,8 @@ public function testBigPipe() { $this->assertSessionCookieExists(TRUE); $this->assertBigPipeNoJsCookieExists(FALSE); + $log_count = db_query('SELECT COUNT(*) FROM {watchdog}')->fetchField(); + // By not calling performMetaRefresh() here, we simulate JavaScript being // enabled, because as far as the BigPipe module is concerned, JavaScript is // enabled in the browser as long as the BigPipe no-JS cookie is *not* set. @@ -180,6 +183,14 @@ public function testBigPipe() { $this->assertFalse(empty($this->getDrupalSettings()), 'drupalSettings present.'); $this->assertTrue(in_array('big_pipe/big_pipe', explode(',', $this->getDrupalSettings()['ajaxPageState']['libraries'])), 'BigPipe asset library is present.'); + // Verify that the two expected exceptions are logged as errors. + $this->assertEqual($log_count + 2, db_query('SELECT COUNT(*) FROM {watchdog}')->fetchField(), 'Two new watchdog entries.'); + $records = db_query('SELECT * FROM {watchdog} ORDER BY wid DESC LIMIT 2')->fetchAll(); + $this->assertEqual(RfcLogLevel::ERROR, $records[0]->severity); + $this->assertTrue(FALSE !== strpos((string) unserialize($records[0]->variables)['@message'], "exception 'Exception' with message 'Oh noes!'")); + $this->assertEqual(RfcLogLevel::ERROR, $records[0]->severity); + $this->assertTrue(FALSE !== strpos((string) unserialize($records[1]->variables)['@message'], "exception 'Exception' with message 'You are not allowed to say llamas are not cool!'")); + // Verify that 4xx responses work fine. (4xx responses are handled by // subrequests to a route pointing to a controller with the desired output.) $this->drupalGet(Url::fromUri('base:non-existing-path'));