diff --git a/core/modules/dblog/src/Controller/DbLogController.php b/core/modules/dblog/src/Controller/DbLogController.php index 722759f..d6dcfab 100644 --- a/core/modules/dblog/src/Controller/DbLogController.php +++ b/core/modules/dblog/src/Controller/DbLogController.php @@ -276,7 +276,7 @@ public function eventDetails($event_id) { ), array( array('data' => $this->t('Operations'), 'header' => TRUE), - $dblog->link, + SafeMarkup::checkAdminXss($dblog->link), ), ); $build['dblog_table'] = array( diff --git a/core/modules/dblog/src/Tests/DbLogTest.php b/core/modules/dblog/src/Tests/DbLogTest.php index 848c1ab..275aa33 100644 --- a/core/modules/dblog/src/Tests/DbLogTest.php +++ b/core/modules/dblog/src/Tests/DbLogTest.php @@ -7,9 +7,11 @@ namespace Drupal\dblog\Tests; +use Drupal\Component\Utility\String; use Drupal\Component\Utility\Unicode; use Drupal\Component\Utility\Xss; use Drupal\Core\Logger\RfcLogLevel; +use Drupal\Core\Url; use Drupal\dblog\Controller\DbLogController; use Drupal\simpletest\WebTestBase; @@ -55,37 +57,6 @@ protected function setUp() { } /** - * Tests Database Logging module functionality through interfaces. - * - * First logs in users, then creates database log events, and finally tests - * Database Logging module functionality through both the admin and user - * interfaces. - */ - function testDbLog() { - // Login the admin user. - $this->drupalLogin($this->adminUser); - - $row_limit = 100; - $this->verifyRowLimit($row_limit); - $this->verifyCron($row_limit); - $this->verifyEvents(); - $this->verifyReports(); - $this->verifyBreadcrumbs(); - // Verify the overview table sorting. - $orders = array('Date', 'Type', 'User'); - $sorts = array('asc', 'desc'); - foreach ($orders as $order) { - foreach ($sorts as $sort) { - $this->verifySort($sort, $order); - } - } - - // Login the regular user. - $this->drupalLogin($this->webUser); - $this->verifyReports(403); - } - - /** * Verifies setting of the database log row limit. * * @param int $row_limit @@ -129,21 +100,33 @@ private function verifyCron($row_limit) { * * @param int $count * Number of watchdog entries to generate. - * @param string $type - * (optional) The type of watchdog entry. Defaults to 'custom'. - * @param int $severity - * (optional) The severity of the watchdog entry. Defaults to - * \Drupal\Core\Logger\RfcLogLevel::NOTICE. + * @param array $options + * These options are used to override the defaults for the test. + * An associative array containing any of the following keys: + * - 'channel': String identifying the log channel to be output to. + * If the channel is not set, the default of 'custom' will be used. + * - 'message': String containing a message to be output to the log. + * A simple default message is used if not provided. + * - 'variables': Array of variables that match the message string. + * - 'severity': Log severity level as defined in logging_severity_levels. + * - 'link': String linking to view the result of the event. + * - 'user': String identifying the username. + * - 'uid': Int identifying the user id for the user. + * - 'request_uri': String identifying the location of the request. + * - 'referer': String identifying the referring url. + * - 'ip': String The ip address of the client machine triggering the log + * entry. + * - 'timestamp': Int unix timestamp. */ - private function generateLogEntries($count, $type = 'custom', $severity = RfcLogLevel::NOTICE) { + private function generateLogEntries($count, $options = array()) { global $base_root; // Prepare the fields to be logged - $log = array( - 'channel' => $type, - 'message' => 'Log entry added to test the dblog row limit.', + $log = $options + array( + 'channel' => 'custom', + 'message' => 'Dblog test log message', 'variables' => array(), - 'severity' => $severity, + 'severity' => RfcLogLevel::NOTICE, 'link' => NULL, 'user' => $this->adminUser, 'uid' => $this->adminUser->id(), @@ -151,11 +134,13 @@ private function generateLogEntries($count, $type = 'custom', $severity = RfcLog 'referer' => \Drupal::request()->server->get('HTTP_REFERER'), 'ip' => '127.0.0.1', 'timestamp' => REQUEST_TIME, - ); - $message = 'Log entry added to test the dblog row limit. Entry #'; + ); + + $logger = $this->container->get('logger.dblog'); + $message = $log['message'] . ' Entry #'; for ($i = 0; $i < $count; $i++) { $log['message'] = $message . $i; - $this->container->get('logger.dblog')->log($severity, $log['message'], $log); + $logger->log($log['severity'], $log['message'], $log); } } @@ -497,7 +482,10 @@ public function testFilter() { 'type' => $type_name, 'severity' => $severity++, ); - $this->generateLogEntries($type['count'], $type['type'], $type['severity']); + $this->generateLogEntries($type['count'], array( + 'channel' => $type['type'], + 'severity' => $type['severity'], + )); } }