diff --git a/core/modules/dblog/config/optional/views.view.watchdog.yml b/core/modules/dblog/config/optional/views.view.watchdog.yml index a805ca598895574cd204a5e375f8410889b1571c..f3751808babb7c9c0d0eb4085ebff6cfa86329a6 100644 --- a/core/modules/dblog/config/optional/views.view.watchdog.yml +++ b/core/modules/dblog/config/optional/views.view.watchdog.yml @@ -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 diff --git a/core/modules/dblog/dblog.install b/core/modules/dblog/dblog.install index 8da830b310e57fac146e5e66d91c53e599eb5679..f180e1e3fce1ae9f2dafced5f4e8c1a597ce648f 100644 --- a/core/modules/dblog/dblog.install +++ b/core/modules/dblog/dblog.install @@ -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(); + } +} diff --git a/core/modules/dblog/tests/src/Functional/DbLogViewsTest.php b/core/modules/dblog/tests/src/Functional/DbLogViewsTest.php index d04d9ba15428af7c51be0e33d5ef1ff627d3f115..6e525cdf6f9dfe748dc91c5c02694637384eef6d 100644 --- a/core/modules/dblog/tests/src/Functional/DbLogViewsTest.php +++ b/core/modules/dblog/tests/src/Functional/DbLogViewsTest.php @@ -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 @@ protected function filterLogsEntries($type = NULL, $severity = NULL) { } /** - * {@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' => '


', - ], - ], - ], - ]); - $basic_html_format->save(); - - parent::testDBLogAddAndClear(); + public function testEmptyText() { + $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']); } } diff --git a/core/modules/dblog/tests/src/Functional/Update/DblogNoLogsAvailableUpgradeTest.php b/core/modules/dblog/tests/src/Functional/Update/DblogNoLogsAvailableUpgradeTest.php new file mode 100644 index 0000000000000000000000000000000000000000..b4bfc282541fe8d68132dc02aabd4643d3efa74f --- /dev/null +++ b/core/modules/dblog/tests/src/Functional/Update/DblogNoLogsAvailableUpgradeTest.php @@ -0,0 +1,42 @@ +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']); + } + +}