Commit f2d177a0 authored by catch's avatar catch

Revert "Issue #2015149 by dagmar, Jo Fitzgerald, hanoii, pritish.kumar, Pol,...

Revert "Issue #2015149 by dagmar, Jo Fitzgerald, hanoii, pritish.kumar, Pol, Lendude, damiankloip, nicolas.rafaelli, alansaviolobo, Psikik, yoroy, dawehner, alexpott, catch, jibran: Replace dblog recent log entries with a view"

This reverts commit c99c526c.
parent c99c526c
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\views\ViewEntityInterface; use Drupal\views\ViewEntityInterface;
use Drupal\views\ViewExecutable;
/** /**
* Implements hook_help(). * Implements hook_help().
...@@ -188,12 +187,3 @@ function dblog_view_presave(ViewEntityInterface $view) { ...@@ -188,12 +187,3 @@ function dblog_view_presave(ViewEntityInterface $view) {
$view->set('display', $displays); $view->set('display', $displays);
} }
} }
/**
* Implements hook_views_pre_render().
*/
function dblog_views_pre_render(ViewExecutable $view) {
if (isset($view) && ($view->storage->get('base_table') == 'watchdog')) {
$view->element['#attached']['library'][] = 'dblog/drupal.dblog';
}
}
<?php
/**
* @file
* Post update functions for the Database Logging module.
*/
use Drupal\Core\Config\FileStorage;
use Drupal\Core\Config\InstallStorage;
use Drupal\views\Entity\View;
/**
* Replace 'Recent log messages' with a view.
*/
function dblog_post_update_convert_recent_messages_to_view() {
// Only create if the views module is enabled and the watchdog view doesn't
// exist.
if (\Drupal::moduleHandler()->moduleExists('views')) {
if (!View::load('watchdog')) {
// Save the watchdog view to config.
$module_handler = \Drupal::moduleHandler();
$optional_install_path = $module_handler->getModule('dblog')->getPath() . '/' . InstallStorage::CONFIG_OPTIONAL_DIRECTORY;
$storage = new FileStorage($optional_install_path);
\Drupal::entityTypeManager()
->getStorage('view')
->create($storage->read('views.view.watchdog'))
->save();
return t('The watchdog view has been created.');
}
return t("The watchdog view already exists and was not replaced. To replace the 'Recent log messages' with a view, rename the watchdog view and uninstall and install the 'Database Log' module");
}
}
<?php
namespace Drupal\dblog\Tests\Update;
use Drupal\system\Tests\Update\UpdatePathTestBase;
/**
* Ensures that update hook that creates the watchdog view ran sucessfully.
*
* @group Update
*/
class DblogRecentLogsUsingViewsUpdateTest extends UpdatePathTestBase {
/**
* {@inheritdoc}
*/
protected function setDatabaseDumpFiles() {
$this->databaseDumpFiles = [
__DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
];
}
/**
* Ensures that update hook is run for dblog module.
*/
public function testUpdate() {
// Make sure the watchog view doesn't exist before the updates.
$view = \Drupal::entityTypeManager()->getStorage('view')->load('watchdog');
$this->assertNull($view);
$this->runUpdates();
// Ensure the watchdog view is present after run updates.
$view = \Drupal::entityTypeManager()->getStorage('view')->load('watchdog');
$displays = $view->get('display');
$this->assertIdentical($displays['page']['display_options']['path'], 'admin/reports/dblog', 'Recent logs message view exists.');
}
}
...@@ -253,10 +253,10 @@ protected function clearLogsEntries() { ...@@ -253,10 +253,10 @@ protected function clearLogsEntries() {
*/ */
protected function filterLogsEntries($type = NULL, $severity = NULL) { protected function filterLogsEntries($type = NULL, $severity = NULL) {
$edit = []; $edit = [];
if (isset($type)) { if (!is_null($type)) {
$edit['type[]'] = $type; $edit['type[]'] = $type;
} }
if (isset($severity)) { if (!is_null($severity)) {
$edit['severity[]'] = $severity; $edit['severity[]'] = $severity;
} }
$this->drupalPostForm(NULL, $edit, t('Filter')); $this->drupalPostForm(NULL, $edit, t('Filter'));
...@@ -283,12 +283,6 @@ private function verifyReports($response = 200) { ...@@ -283,12 +283,6 @@ private function verifyReports($response = 200) {
$this->assertText(t('Recent log messages'), 'DBLog report was displayed'); $this->assertText(t('Recent log messages'), 'DBLog report was displayed');
} }
$this->drupalGet('admin/reports/dblog/confirm');
$this->assertResponse($response);
if ($response == 200) {
$this->assertText(t('Are you sure you want to delete the recent logs?'), 'DBLog clear logs form was displayed');
}
// View the database log page-not-found report page. // View the database log page-not-found report page.
$this->drupalGet('admin/reports/page-not-found'); $this->drupalGet('admin/reports/page-not-found');
$this->assertResponse($response); $this->assertResponse($response);
...@@ -810,7 +804,7 @@ public function testOverviewLinks() { ...@@ -810,7 +804,7 @@ public function testOverviewLinks() {
$this->drupalGet('admin/reports/dblog'); $this->drupalGet('admin/reports/dblog');
$this->assertResponse(200); $this->assertResponse(200);
// Make sure HTML tags are filtered out. // Make sure HTML tags are filtered out.
$this->assertRaw('title="alert(&#039;foo&#039;);Lorem'); $this->assertRaw('title="alert(&#039;foo&#039;);Lorem ipsum dolor sit amet, consectetur adipiscing &amp; elit. Entry #0">&lt;script&gt;alert(&#039;foo&#039;);&lt;/script&gt;Lorem ipsum dolor sit…</a>');
$this->assertNoRaw("<script>alert('foo');</script>"); $this->assertNoRaw("<script>alert('foo');</script>");
// Make sure HTML tags are filtered out in admin/reports/dblog/event/ too. // Make sure HTML tags are filtered out in admin/reports/dblog/event/ too.
......
<?php
namespace Drupal\Tests\dblog\Functional;
use Drupal\filter\Entity\FilterFormat;
/**
* Generate events and verify dblog entries; verify user access to log reports
* based on permissions. Using the dblog UI generated by a View.
*
* @see Drupal\dblog\Tests\DbLogTest
*
* @group dblog
*/
class DbLogViewsTest extends DbLogTest {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = ['dblog', 'node', 'forum', 'help', 'block', 'views'];
/**
* {@inheritdoc}
*/
protected function getLogsEntriesTable() {
return $this->xpath('.//table[contains(@class, "views-view-table")]/tbody/tr');
}
/**
* {@inheritdoc}
*/
protected function filterLogsEntries($type = NULL, $severity = NULL) {
$query = [];
if (isset($type)) {
$query['type[]'] = $type;
}
if (isset($severity)) {
$query['severity[]'] = $severity;
}
$this->drupalGet('admin/reports/dblog', ['query' => $query]);
}
/**
* {@inheritdoc}
*/
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();
parent::testDBLogAddAndClear();
}
}
...@@ -65,7 +65,7 @@ protected function getEntityCounts() { ...@@ -65,7 +65,7 @@ protected function getEntityCounts() {
'user' => 7, 'user' => 7,
'user_role' => 6, 'user_role' => 6,
'menu_link_content' => 4, 'menu_link_content' => 4,
'view' => 15, 'view' => 14,
'date_format' => 11, 'date_format' => 11,
'entity_form_display' => 19, 'entity_form_display' => 19,
'entity_form_mode' => 1, 'entity_form_mode' => 1,
......
...@@ -66,7 +66,7 @@ protected function getEntityCounts() { ...@@ -66,7 +66,7 @@ protected function getEntityCounts() {
'user' => 4, 'user' => 4,
'user_role' => 3, 'user_role' => 3,
'menu_link_content' => 7, 'menu_link_content' => 7,
'view' => 15, 'view' => 14,
'date_format' => 11, 'date_format' => 11,
'entity_form_display' => 18, 'entity_form_display' => 18,
'entity_form_mode' => 1, 'entity_form_mode' => 1,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment