diff --git a/core/modules/dblog/lib/Drupal/dblog/Plugin/views/field/DblogMessage.php b/core/modules/dblog/lib/Drupal/dblog/Plugin/views/field/DblogMessage.php index a0c1e1e..3d17745 100644 --- a/core/modules/dblog/lib/Drupal/dblog/Plugin/views/field/DblogMessage.php +++ b/core/modules/dblog/lib/Drupal/dblog/Plugin/views/field/DblogMessage.php @@ -31,7 +31,7 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o parent::init($view, $display, $options); if ($this->options['replace_variables']) { - $this->additional_fields[] = 'variables'; + $this->additional_fields['variables'] = 'variables'; } } diff --git a/core/modules/dblog/lib/Drupal/dblog/Tests/Views/ViewsIntegrationTest.php b/core/modules/dblog/lib/Drupal/dblog/Tests/Views/ViewsIntegrationTest.php index 9c0f219..23f6310 100644 --- a/core/modules/dblog/lib/Drupal/dblog/Tests/Views/ViewsIntegrationTest.php +++ b/core/modules/dblog/lib/Drupal/dblog/Tests/Views/ViewsIntegrationTest.php @@ -49,22 +49,56 @@ protected function setUp() { * Tests the integration. */ public function testIntegration() { + + // Remove the watchdog entries added by the potential batch process. + $this->container->get('database')->truncate('watchdog')->execute(); + $entries = array(); + // Setup a watchdog entry without tokens. $entries[] = array( 'message' => $this->randomName(), + 'variables' => array(), + 'link' => l('Link', 'node/1'), + ); + // Setup a watchdog entry with one token. + $entries[] = array( + 'message' => '@token1', + 'variables' => array('@token1' => $this->randomName()), + 'link' => l('Link', 'node/2'), + ); + // Setup a watchdog entry with two tokens. + $entries[] = array( + 'message' => '@token1 !token2', + 'variables' => array('@token1' => $this->randomName(), '!token2' => $this->randomName()), + // Setup a link with a tag which is filtered by filter_xss_admin. + 'link' => l('Link', 'node/2', array('html' => TRUE)), ); foreach ($entries as $entry) { $entry += array( 'type' => 'test-views', - 'variables' => array(), + 'severity' => WATCHDOG_NOTICE, ); - watchdog($entry['type'], $entry['message']); + watchdog($entry['type'], $entry['message'], $entry['variables'], $entry['severity'], $entry['link']); } $view = views_get_view('test_dblog'); $this->executeView($view); + $view->initStyle(); + + foreach ($entries as $index => $entry) { + $this->assertEqual($view->style_plugin->get_field($index, 'message'), format_string($entry['message'], $entry['variables'])); + $this->assertEqual($view->style_plugin->get_field($index, 'link'), filter_xss_admin($entry['link'])); + } - // @todo Add test assertions. + // Disable replacing variables and check that the tokens aren't replaced. + $view->destroy(); + $view->initHandlers(); + $this->executeView($view); + $view->initStyle(); + $view->field['message']->options['replace_variables'] = FALSE; + foreach ($entries as $index => $entry) { + $this->assertEqual($view->style_plugin->get_field($index, 'message'), $entry['message']); + } } } diff --git a/core/modules/dblog/tests/modules/dblog_test_views/test_views/views.view.test_dblog.yml b/core/modules/dblog/tests/modules/dblog_test_views/test_views/views.view.test_dblog.yml index c826832..5c5c0da 100644 --- a/core/modules/dblog/tests/modules/dblog_test_views/test_views/views.view.test_dblog.yml +++ b/core/modules/dblog/tests/modules/dblog_test_views/test_views/views.view.test_dblog.yml @@ -25,50 +25,21 @@ display: row: type: fields fields: - hostname: - id: hostname - table: watchdog - field: hostname - link: - id: link - table: watchdog - field: link - location: - id: location + wid: + id: wid table: watchdog - field: location + field: wid + plugin_id: numeric message: id: message table: watchdog field: message - referer: - id: referer - table: watchdog - field: referer - severity: - id: severity - table: watchdog - field: severity - timestamp: - id: timestamp - table: watchdog - field: timestamp - type: - id: type - table: watchdog - field: type - uid: - id: uid - table: watchdog - field: uid - variables: - id: variables - table: watchdog - field: variables - wid: - id: wid + plugin_id: dblog_message + link: + id: link table: watchdog - field: wid + field: link + plugin_id: dblog_operations filters: { } sorts: wid: @@ -76,6 +47,7 @@ display: table: watchdog field: wid order: ASC + plugin_id: standard page_1: display_plugin: page id: page_1