updated core to 8.6.1 via composer
This commit is contained in:
@@ -652,18 +652,16 @@ display:
|
||||
footer: { }
|
||||
empty:
|
||||
area:
|
||||
id: area
|
||||
id: area_text_custom
|
||||
table: views
|
||||
field: area
|
||||
field: area_text_custom
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
admin_label: 'No log messages available.'
|
||||
empty: true
|
||||
tokenize: false
|
||||
content:
|
||||
value: 'No log messages available.'
|
||||
format: basic_html
|
||||
plugin_id: text
|
||||
content: 'No log messages available.'
|
||||
plugin_id: text_custom
|
||||
relationships:
|
||||
uid:
|
||||
id: uid
|
||||
|
||||
@@ -156,3 +156,42 @@ function dblog_update_8400() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Change 'No logs message available.' area plugin type.
|
||||
*/
|
||||
function dblog_update_8600() {
|
||||
$config_factory = \Drupal::configFactory();
|
||||
|
||||
$view = \Drupal::configFactory()->getEditable('views.view.watchdog');
|
||||
if (empty($view)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$empty_text = $view->get('display.default.display_options.empty');
|
||||
if (!isset($empty_text['area']['content']['value'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Only update the empty text if is untouched from the original version.
|
||||
if ($empty_text['area']['id'] == 'area' &&
|
||||
$empty_text['area']['plugin_id'] == 'text' &&
|
||||
$empty_text['area']['field'] == 'area' &&
|
||||
$empty_text['area']['content']['value'] == 'No log messages available.') {
|
||||
|
||||
$new_config = [
|
||||
'id' => 'area_text_custom',
|
||||
'table' => 'views',
|
||||
'field' => 'area_text_custom',
|
||||
'relationship' => 'none',
|
||||
'group_type' => 'group',
|
||||
'admin_label' => 'No log messages available.',
|
||||
'empty' => TRUE,
|
||||
'tokenize' => FALSE,
|
||||
'content' => 'No log messages available.',
|
||||
'plugin_id' => 'text_custom',
|
||||
];
|
||||
$view->set('display.default.display_options.empty.area', $new_config);
|
||||
$view->save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ function dblog_form_system_logging_settings_alter(&$form, FormStateInterface $fo
|
||||
'#title' => t('Database log messages to keep'),
|
||||
'#default_value' => \Drupal::configFactory()->getEditable('dblog.settings')->get('row_limit'),
|
||||
'#options' => [0 => t('All')] + array_combine($row_limits, $row_limits),
|
||||
'#description' => t('The maximum number of messages to keep in the database log. Requires a <a href=":cron">cron maintenance task</a>.', [':cron' => \Drupal::url('system.status')])
|
||||
'#description' => t('The maximum number of messages to keep in the database log. Requires a <a href=":cron">cron maintenance task</a>.', [':cron' => \Drupal::url('system.status')]),
|
||||
];
|
||||
|
||||
$form['#submit'][] = 'dblog_logging_settings_submit';
|
||||
|
||||
@@ -113,7 +113,8 @@ class DbLogController extends ControllerBase {
|
||||
* Full-length messages can be viewed on the message details page.
|
||||
*
|
||||
* @return array
|
||||
* A render array as expected by drupal_render().
|
||||
* A render array as expected by
|
||||
* \Drupal\Core\Render\RendererInterface::render().
|
||||
*
|
||||
* @see Drupal\dblog\Form\DblogClearLogConfirmForm
|
||||
* @see Drupal\dblog\Controller\DbLogController::eventDetails()
|
||||
@@ -237,7 +238,7 @@ class DbLogController extends ControllerBase {
|
||||
*
|
||||
* @return array
|
||||
* If the ID is located in the Database Logging table, a build array in the
|
||||
* format expected by drupal_render();
|
||||
* format expected by \Drupal\Core\Render\RendererInterface::render().
|
||||
*/
|
||||
public function eventDetails($event_id) {
|
||||
$build = [];
|
||||
@@ -378,7 +379,8 @@ class DbLogController extends ControllerBase {
|
||||
* Type of database log events to display (e.g., 'search').
|
||||
*
|
||||
* @return array
|
||||
* A build array in the format expected by drupal_render().
|
||||
* A build array in the format expected by
|
||||
* \Drupal\Core\Render\RendererInterface::render().
|
||||
*/
|
||||
public function topLogMessages($type) {
|
||||
$header = [
|
||||
@@ -411,7 +413,7 @@ class DbLogController extends ControllerBase {
|
||||
}
|
||||
}
|
||||
|
||||
$build['dblog_top_table'] = [
|
||||
$build['dblog_top_table'] = [
|
||||
'#type' => 'table',
|
||||
'#header' => $header,
|
||||
'#rows' => $rows,
|
||||
|
||||
@@ -68,7 +68,7 @@ class DblogClearLogConfirmForm extends ConfirmFormBase {
|
||||
public function submitForm(array &$form, FormStateInterface $form_state) {
|
||||
$_SESSION['dblog_overview_filter'] = [];
|
||||
$this->connection->truncate('watchdog')->execute();
|
||||
drupal_set_message($this->t('Database log cleared.'));
|
||||
$this->messenger()->addStatus($this->t('Database log cleared.'));
|
||||
$form_state->setRedirectUrl($this->getCancelUrl());
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace Drupal\dblog\Logger;
|
||||
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\Core\Database\Connection;
|
||||
use Drupal\Core\Database\Database;
|
||||
use Drupal\Core\Database\DatabaseException;
|
||||
@@ -57,8 +56,8 @@ class DbLog implements LoggerInterface {
|
||||
// Remove any backtraces since they may contain an unserializable variable.
|
||||
unset($context['backtrace']);
|
||||
|
||||
// Convert PSR3-style messages to SafeMarkup::format() style, so they can be
|
||||
// translated too in runtime.
|
||||
// Convert PSR3-style messages to \Drupal\Component\Render\FormattableMarkup
|
||||
// style, so they can be translated too in runtime.
|
||||
$message_placeholders = $this->parser->parseMessagePlaceholders($message, $context);
|
||||
|
||||
try {
|
||||
@@ -66,14 +65,14 @@ class DbLog implements LoggerInterface {
|
||||
->insert('watchdog')
|
||||
->fields([
|
||||
'uid' => $context['uid'],
|
||||
'type' => Unicode::substr($context['channel'], 0, 64),
|
||||
'type' => mb_substr($context['channel'], 0, 64),
|
||||
'message' => $message,
|
||||
'variables' => serialize($message_placeholders),
|
||||
'severity' => $level,
|
||||
'link' => $context['link'],
|
||||
'location' => $context['request_uri'],
|
||||
'referer' => $context['referer'],
|
||||
'hostname' => Unicode::substr($context['ip'], 0, 128),
|
||||
'hostname' => mb_substr($context['ip'], 0, 128),
|
||||
'timestamp' => $context['timestamp'],
|
||||
])
|
||||
->execute();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Drupal\dblog\Plugin\views\field;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\views\Plugin\views\field\FieldPluginBase;
|
||||
use Drupal\views\ResultRow;
|
||||
@@ -60,7 +60,7 @@ class DblogMessage extends FieldPluginBase {
|
||||
|
||||
if ($this->options['replace_variables']) {
|
||||
$variables = unserialize($this->getvalue($values, 'variables'));
|
||||
return SafeMarkup::format($value, (array) $variables);
|
||||
return new FormattableMarkup($value, (array) $variables);
|
||||
}
|
||||
else {
|
||||
return $this->sanitizeValue($value);
|
||||
|
||||
@@ -5,5 +5,5 @@ package: Testing
|
||||
version: VERSION
|
||||
core: 8.x
|
||||
dependencies:
|
||||
- dblog
|
||||
- views
|
||||
- drupal:dblog
|
||||
- drupal:views
|
||||
|
||||
@@ -18,6 +18,7 @@ use Drupal\Tests\Traits\Core\CronRunTrait;
|
||||
*/
|
||||
class DbLogTest extends BrowserTestBase {
|
||||
use CronRunTrait;
|
||||
use FakeLogEntries;
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
@@ -182,55 +183,6 @@ class DbLogTest extends BrowserTestBase {
|
||||
return $current_id - $last_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a number of random database log events.
|
||||
*
|
||||
* @param int $count
|
||||
* Number of watchdog entries to generate.
|
||||
* @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, $options = []) {
|
||||
global $base_root;
|
||||
|
||||
// Prepare the fields to be logged
|
||||
$log = $options + [
|
||||
'channel' => 'custom',
|
||||
'message' => 'Dblog test log message',
|
||||
'variables' => [],
|
||||
'severity' => RfcLogLevel::NOTICE,
|
||||
'link' => NULL,
|
||||
'user' => $this->adminUser,
|
||||
'uid' => $this->adminUser->id(),
|
||||
'request_uri' => $base_root . \Drupal::request()->getRequestUri(),
|
||||
'referer' => \Drupal::request()->server->get('HTTP_REFERER'),
|
||||
'ip' => '127.0.0.1',
|
||||
'timestamp' => REQUEST_TIME,
|
||||
];
|
||||
|
||||
$logger = $this->container->get('logger.dblog');
|
||||
$message = $log['message'] . ' Entry #';
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$log['message'] = $message . $i;
|
||||
$logger->log($log['severity'], $log['message'], $log);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the entry logs by clicking on 'Clear log messages' button.
|
||||
*/
|
||||
@@ -432,7 +384,7 @@ class DbLogTest extends BrowserTestBase {
|
||||
$value = $links->getAttribute('href');
|
||||
|
||||
// Extract link to details page.
|
||||
$link = Unicode::substr($value, strpos($value, 'admin/reports/dblog/event/'));
|
||||
$link = mb_substr($value, strpos($value, 'admin/reports/dblog/event/'));
|
||||
$this->drupalGet($link);
|
||||
// Check for full message text on the details page.
|
||||
$this->assertRaw($message, 'DBLog event details was found: [delete user]');
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Drupal\Tests\dblog\Functional;
|
||||
|
||||
use Drupal\filter\Entity\FilterFormat;
|
||||
use Drupal\views\Views;
|
||||
|
||||
/**
|
||||
* Generate events and verify dblog entries; verify user access to log reports
|
||||
@@ -44,27 +44,16 @@ class DbLogViewsTest extends DbLogTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* Tests the empty text for the watchdog view is not using an input format.
|
||||
*/
|
||||
public function testDBLogAddAndClear() {
|
||||
// Is necesary to create the basic_html format because if absent after
|
||||
// delete the logs, a new log entry is created indicating that basic_html
|
||||
// format do not exists.
|
||||
$basic_html_format = FilterFormat::create([
|
||||
'format' => 'basic_html',
|
||||
'name' => 'Basic HTML',
|
||||
'filters' => [
|
||||
'filter_html' => [
|
||||
'status' => 1,
|
||||
'settings' => [
|
||||
'allowed_html' => '<p> <br> <strong> <a> <em>',
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
$basic_html_format->save();
|
||||
public function testEmptyText() {
|
||||
$view = Views::getView('watchdog');
|
||||
$data = $view->storage->toArray();
|
||||
$area = $data['display']['default']['display_options']['empty']['area'];
|
||||
|
||||
parent::testDBLogAddAndClear();
|
||||
$this->assertEqual('text_custom', $area['plugin_id']);
|
||||
$this->assertEqual('area_text_custom', $area['field']);
|
||||
$this->assertEqual('No log messages available.', $area['content']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\dblog\Functional;
|
||||
|
||||
use Drupal\Core\Logger\RfcLogLevel;
|
||||
use Drupal\Core\Session\AnonymousUserSession;
|
||||
|
||||
/**
|
||||
* Provides methods to generate log entries.
|
||||
*
|
||||
* This trait is meant to be used only by test classes.
|
||||
*/
|
||||
trait FakeLogEntries {
|
||||
|
||||
/**
|
||||
* Generates a number of random database log events.
|
||||
*
|
||||
* @param int $count
|
||||
* Number of watchdog entries to generate.
|
||||
* @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, $options = []) {
|
||||
global $base_root;
|
||||
|
||||
$user = !empty($this->adminUser) ? $this->adminUser : new AnonymousUserSession();
|
||||
|
||||
// Prepare the fields to be logged.
|
||||
$log = $options + [
|
||||
'channel' => 'custom',
|
||||
'message' => 'Dblog test log message',
|
||||
'variables' => [],
|
||||
'severity' => RfcLogLevel::NOTICE,
|
||||
'link' => NULL,
|
||||
'user' => $user,
|
||||
'uid' => $user->id(),
|
||||
'request_uri' => $base_root . \Drupal::request()->getRequestUri(),
|
||||
'referer' => \Drupal::request()->server->get('HTTP_REFERER'),
|
||||
'ip' => '127.0.0.1',
|
||||
'timestamp' => REQUEST_TIME,
|
||||
];
|
||||
|
||||
$logger = $this->container->get('logger.dblog');
|
||||
$message = $log['message'] . ' Entry #';
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$log['message'] = $message . $i;
|
||||
$logger->log($log['severity'], $log['message'], $log);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,6 +12,7 @@ use Drupal\Core\Serialization\Yaml;
|
||||
* @see dblog_update_8400()
|
||||
*
|
||||
* @group Update
|
||||
* @group legacy
|
||||
*/
|
||||
class DblogFiltersAndFieldsUpgradeTest extends UpdatePathTestBase {
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\dblog\Functional\Update;
|
||||
|
||||
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
|
||||
use Drupal\views\Views;
|
||||
|
||||
/**
|
||||
* Test the upgrade path of changing the emtpy text area for watchdog view.
|
||||
*
|
||||
* @see dblog_update_8600()
|
||||
*
|
||||
* @group Update
|
||||
* @group legacy
|
||||
*/
|
||||
class DblogNoLogsAvailableUpgradeTest extends UpdatePathTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setDatabaseDumpFiles() {
|
||||
$this->databaseDumpFiles = [
|
||||
__DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.4.0.bare.standard.php.gz',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that no logs available text is now using a custom area.
|
||||
*/
|
||||
public function testDblogUpgradePath() {
|
||||
|
||||
$this->runUpdates();
|
||||
|
||||
$view = Views::getView('watchdog');
|
||||
$data = $view->storage->toArray();
|
||||
$area = $data['display']['default']['display_options']['empty']['area'];
|
||||
|
||||
$this->assertEqual('text_custom', $area['plugin_id']);
|
||||
$this->assertEqual('area_text_custom', $area['field']);
|
||||
$this->assertEqual('No log messages available.', $area['content']);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,6 +8,7 @@ use Drupal\FunctionalTests\Update\UpdatePathTestBase;
|
||||
* Ensures that update hook that creates the watchdog view ran sucessfully.
|
||||
*
|
||||
* @group Update
|
||||
* @group legacy
|
||||
*/
|
||||
class DblogRecentLogsUsingViewsUpdateTest extends UpdatePathTestBase {
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Drupal\Tests\dblog\Kernel\Views;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Component\Utility\Xss;
|
||||
use Drupal\Core\Logger\RfcLogLevel;
|
||||
use Drupal\Core\Url;
|
||||
@@ -62,7 +62,7 @@ class ViewsIntegrationTest extends ViewsKernelTestBase {
|
||||
if (!isset($entry['variables'])) {
|
||||
continue;
|
||||
}
|
||||
$this->assertEqual($view->style_plugin->getField($index, 'message'), SafeMarkup::format($entry['message'], $entry['variables']));
|
||||
$this->assertEqual($view->style_plugin->getField($index, 'message'), new FormattableMarkup($entry['message'], $entry['variables']));
|
||||
$link_field = $view->style_plugin->getField($index, 'link');
|
||||
// The 3rd entry contains some unsafe markup that needs to get filtered.
|
||||
if ($index == 2) {
|
||||
|
||||
Reference in New Issue
Block a user