Problem/Motivation

#1874534: Introduce a dblog / watchdog views integration Introduced dblog views integration. Now is possible to replace the logs report with a view.

Proposed resolution

  • Provide the a view to administer logs.
  • Keep the original admin as fallback.

Remaining tasks

User interface changes

The fieldset for Filter Log Messages has been removed, the exposed filters for Severity and Type are always visible.

Without views

With views

API changes

None

Data model changes

None

Original report by klonos

In #1874534-27: Introduce a dblog / watchdog views integration @Psikik added this but it was deemed best to put it in a separate follow-up issue. Well, here it is ;)

CommentFileSizeAuthor
#169 interdiff-2015149-164-169.txt2.27 KBdagmar
#169 2015149-169-test-only.patch29.11 KBdagmar
#169 2015149-169.patch29.1 KBdagmar
#168 watchdog.txt19 KBmondrake
#164 interdiff-2015149-158-164.txt1.39 KBdagmar
#164 2015149-164.patch28.2 KBdagmar
#158 interdiff-2015149-156-158.txt606 bytesdagmar
#158 2015149-158.patch28.33 KBdagmar
#156 2015149-156.patch30.2 KBdagmar
#148 interdiff-2015149-144-148.txt1.09 KBhanoii
#148 2015149-148.patch27.73 KBhanoii
#146 interdiff-2015149-144-146.txt1.09 KBhanoii
#146 2015149-146.patch27.92 KBhanoii
#145 Selection_444.png43.06 KBdagmar
#144 interdiff-2015149-139-144.txt565 bytesnicolas.rafaelli
#144 2015149-144.patch27.7 KBnicolas.rafaelli
#140 interdiff-dblog-views.txt1.33 KBdagmar
#139 2015149-139.patch27.7 KBjofitz
#139 interdiff-137-139.txt1.98 KBjofitz
#137 2015149-137.patch29.01 KBjofitz
#137 interdiff-134-137.txt5.7 KBjofitz
#134 replace_dblog_recent-2015149-134.patch28.78 KBpritish.kumar
#132 replace_dblog_recent-2015149-132.patch36.67 KBpritish.kumar
#126 interdiff-2015149-123-126.txt2.03 KBdagmar
#126 replace_dblog_recent-2015149-126.patch30.32 KBdagmar
#123 replace_dblog_recent-2015149-123.patch29.57 KBdagmar
#123 interdiff-2015149-121-123.txt855 bytesdagmar
#121 interdiff-2015149-95-121.txt2.72 KBdagmar
#121 replace_dblog_recent-2015149-121.patch29.75 KBdagmar
#119 interdiff-2015149-95-119.txt1.95 KBdagmar
#119 replace_dblog_recent-2015149-119.patch29.43 KBdagmar
#1 vdc-dblog-view-2015149-1.patch16.61 KBPsikik
#9 2015149-9.patch17.24 KBdamiankloip
#9 interdiff-2015149-9.txt20.6 KBdamiankloip
#14 Recent log messages d8.x201.local_.png91.17 KBPol
#14 Recent log messages d8.x201.local (1).png82.51 KBPol
#22 replace_dblog_recent-2015149-22.patch21.9 KBalansaviolobo
#26 2015149.patch22.71 KBPol
#31 img-2015149-31.png63.91 KBdagmar
#31 replace_dblog_recent-2015149-31.patch22.66 KBdagmar
#34 replace_dblog_recent-2015149-34.patch23.57 KBdagmar
#34 interdiff-2015149-31-34.txt41.69 KBdagmar
#36 replace_dblog_recent-2015149-36.patch24.74 KBdagmar
#36 interdiff-2015149-34-36.txt1.18 KBdagmar
#39 replace_dblog_recent-2015149-39.patch24.2 KBdagmar
#39 interdiff-2015149-36-39.txt4.01 KBdagmar
#41 replace_dblog_recent-2015149-41.patch24.69 KBdagmar
#41 interdiff-2015149-39-41.txt497 bytesdagmar
#45 replace_dblog_recent-2015149-44.patch31.31 KBdagmar
#45 interdiff-2015149-41-44.txt8.48 KBdagmar
#46 replace_dblog_recent-2015149-46.patch31.41 KBdagmar
#46 interdiff-2015149-44-46.txt2.73 KBdagmar
#47 replace_dblog_recent-2015149-47.patch31.33 KBdagmar
#47 interdiff-2015149-46-47.txt516 bytesdagmar
#49 replace_dblog_recent-2015149-49.patch31.68 KBdagmar
#49 interdiff-2015149-47-49.txt3.54 KBdagmar
#49 2015149-49-views-ui.png54.61 KBdagmar
#49 2015149-49-fallback-ui.png55.06 KBdagmar
#56 delete-log-messages.png68.97 KByoroy
#59 interdiff-2015149-49-59.txt4.16 KBdagmar
#59 replace_dblog_recent-2015149-59.patch26.04 KBdagmar
#60 2015149-60-without-views.png58 KBdagmar
#60 2015149-60-with-views.png55.33 KBdagmar
#61 replace_dblog_recent-2015149-61.patch26.59 KBdagmar
#61 interdiff-2015149-59-61.txt794 bytesdagmar
#66 replace_dblog_recent-2015149-66.patch26.59 KBdagmar
#69 interdiff-2015149-66-69.txt694 bytesdagmar
#69 replace_dblog_recent-2015149-69.patch29.63 KBdagmar
#71 replace_dblog_recent-2015149-71.patch26.66 KBdagmar
#73 interdiff-2015149-71-73.txt602 bytesdagmar
#73 replace_dblog_recent-2015149-73.patch26.66 KBdagmar
#75 interdiff-73-75.txt1.77 KBdagmar
#75 replace_dblog_recent-2015149-75.patch27.83 KBdagmar
#77 replace_dblog_recent-2015149-77.patch27.86 KBdagmar
#77 interdiff-75-77.txt1.58 KBdagmar
#78 interdiff-2015149-77-78.txt2.17 KBLendude
#78 replace_dblog_recent-2015149-78.patch27.84 KBLendude
#83 replace_dblog_recent-2015149-83.patch50.44 KBdagmar
#83 interdiff-2015149-78-83.txt24.25 KBdagmar
#85 replace_dblog_recent-2015149-85.patch50.49 KBdagmar
#85 interdiff-2015149-83-85.txt708 bytesdagmar
#87 replace_dblog_recent-2015149-87.patch50.49 KBdagmar
#87 interdiff-2015149-85-87.txt431 bytesdagmar
#89 interdiff-2015149-87-89.txt714 bytesdagmar
#89 replace_dblog_recent-2015149-89.patch50.5 KBdagmar
#94 interdiff-2015149-89-94.txt22.67 KBdagmar
#94 replace_dblog_recent-2015149-94.patch29.54 KBdagmar
#95 interdiff-2015149-94-95.txt416 bytesdagmar
#95 replace_dblog_recent-2015149-95.patch29.5 KBdagmar
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Psikik’s picture

Here's the view by itself. You'll need to apply the patch in #1874534: Introduce a dblog / watchdog views integration to get this one to work.

alesr’s picture

Reviewed the patch and it looks good.
We should replace /admin/reports/dblog with this view. The view page is currently on /admin/reports/watchdog.

dawehner’s picture

Status: Active » Needs work

Right, we also should set the patch to needs review so we know whether tests do pass.

@@ -0,0 +1,612 @@
+      pager:
+        type: full

We should really use the mini pager.

dawehner’s picture

damiankloip’s picture

Title: Replace dblog recent log entries with a view. » Replace dblog recent log entries with a view
klonos’s picture

Why hate fullstops? :P

damiankloip’s picture

I thought everyone hated fullstops?! No, just me then... ;)

xjm’s picture

damiankloip’s picture

Status: Needs work » Needs review
FileSize
17.24 KB
20.6 KB

Here is a reroll and update of the default view config to add UUID, dependencies, description, properly typed values etc..

dawehner’s picture

Things we have to figure out:

  • Do we want to provide a fallback?
  • Do we want to kill the existing controller/route
  • In case we want to kill, how can we make menu links optional (just in case the route exists)

Status: Needs review » Needs work

The last submitted patch, 9: 2015149-9.patch, failed testing.

damiankloip’s picture

I particularly like point #2 :)

dawehner’s picture

yeah, i hate people which try to bring up always 3 points

Pol’s picture

Hi all,

I just tried this patch and here's my feedback:

  • Patch in #9 is applying and I get the View properly.
  • No bulk operations for Watchdog entry, this could be a solution for the button 'Clear log messages' in the original 'admin/reports/dblog'
  • Missing severity icons.
  • No fieldset around the filters.
  • No text header: 'The Database Logging module monitors your website, capturing...', I edited the view and added it myself on the screenshot.
  • The placement of the shortcut star at the right of the title is different, see the screenshots (With the dblog module and with Views)

I have a bit of free time and I'm willing to work on this, could you guys help me by telling me what to do (and not to do) first ?

Thanks !

dawehner’s picture

No bulk operations for Watchdog entry, this could be a solution for the button 'Clear log messages' in the original 'admin/reports/dblog'

Good idea but sadly as you said reality sucks! I am quite sure that we cannot make watchdog entries entities due to the performance as well as subsystem dependencies problems.

Missing severity icons.

I guess we could drop it but yeah alternative we have to write an alternative field handler.

No fieldset around the filters.

We should not care ... tbh.

No text header: 'The Database Logging module monitors your website, capturing...', I edited the view and added it myself on the screenshot.

Good catch! Could you post a new version of the patch? This is at least a step forward...

The placement of the shortcut star at the right of the title is different, see the screenshots (With the dblog module and with Views)

Oh interesting. Did you figured out why? Is this just a random css problem?

xjm’s picture

No fieldset around the filters.

We should not care ... tbh.

Agreed, we've dropped the fieldset for admin/people and admin/content with the signoff of our usability maintainers. It actually makes the form cleaner.

And yeah, I think we probably want to do the field handler for the icons for this conversion to get in.

Thanks everyone!

Psikik’s picture

Assigned: Unassigned » Psikik

Going to take sometime to update this again.

alansaviolobo’s picture

Related issues: +#488570: Block for dblog

with the fixing of this, https://www.drupal.org/node/488570 could also be closed.

alansaviolobo’s picture

I believe, this would also be a matter of adding another field to the view
https://www.drupal.org/node/155324

Pol’s picture

Never saw the replies till today !

I will provide a new patch within the day probably.

dawehner’s picture

I guess the way forward on this issue is to write a custom area handler for the clear all form and be done with it. This approach should work, even it maybe feels hacky for some people.

alansaviolobo’s picture

Status: Needs work » Needs review
FileSize
21.9 KB

Created a patch with the view for dblog entries.

  • Created a view area handler to embed the 'Clear log messages' form into the header
  • Currently have hard-coded the confirm-delete-form into the handler but was wondering whether it would be a good idea to make it generic by listing out all the forms in the system and let the user select it.
  • Retained the existing listing for comparison purposes.
  • Removed the fieldset around the clear-log-messages button
  • Need help with the markup of the DblogClearLogForm::buildForm method

Status: Needs review » Needs work

The last submitted patch, 22: replace_dblog_recent-2015149-22.patch, failed testing.

jibran’s picture

Issue tags: +Needs reroll
Pol’s picture

I'm going to take care of this.

Pol’s picture

FileSize
22.71 KB

New patch.

URL of the view: admin/structure/views/view/watchdog

I'm trying to get the CSS included when viewing the view page, I'm looking for help on this.

Pol’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 26: 2015149.patch, failed testing.

dcam’s picture

Issue tags: -Needs reroll

#26 applies to HEAD. Removing the "Needs reroll" tag.

mgifford’s picture

Assigned: Psikik » Unassigned

Unassigning stale issue. Hopefully someone else will pursue this.

dagmar’s picture

Version: 8.0.x-dev » 8.2.x-dev
Status: Needs work » Needs review
FileSize
63.91 KB
22.66 KB

In this patch I added the following items:

  1. Icons
  2. New paths admin/reports/watchdog is no longer used
  3. Use twig for replace patterns
  4. Fixed the exposed filter of severity to display human names instead of machine names
  5. Removed the header since dblog automatically adds the instructions for the view

There is a single item I see could be fixed, the Clear Logs button is displayed at the top of the view instead of the bottom.

Screenshot of the current status attached.

Status: Needs review » Needs work

The last submitted patch, 31: replace_dblog_recent-2015149-31.patch, failed testing.

dawehner’s picture

Just a drive by review

  1. +++ b/core/modules/dblog/config/install/views.view.watchdog.yml
    @@ -0,0 +1,721 @@
    +uuid: 070df815-1f3a-4054-8db4-c24922101907
    

    quick nitpick: We don't use UUIDs in exported content

  2. +++ b/core/modules/dblog/src/Plugin/views/area/ClearLogForm.php
    @@ -0,0 +1,34 @@
    +      $form = \Drupal::formBuilder()->getForm('Drupal\dblog\Form\DblogClearLogForm');
    

    Let's inject the form builder ...

  3. +++ b/core/modules/dblog/src/Plugin/views/area/ClearLogForm.php
    @@ -0,0 +1,34 @@
    +      $form['dblog_clear']['#attached']['library'] = ['dblog/drupal.dblog'];
    

    I'm a bit curious why the form itself doesn't include the library ...

dagmar’s picture

Status: Needs work » Needs review
FileSize
23.57 KB
41.69 KB

Thanks @dawehner

I moved the view into config/optional, I hope this fix the 100 errors from the previous test.

quick nitpick: We don't use UUIDs in exported content

Done.

Let's inject the form builder ...

Please let me know if you meant the code I included in init() method.

I'm a bit curious why the form itself doesn't include the library

This is because the library for the CSS is added in the the table and we where not rendering the table. I attached the same library to the clear log button form.

Status: Needs review » Needs work

The last submitted patch, 34: replace_dblog_recent-2015149-34.patch, failed testing.

dagmar’s picture

Status: Needs work » Needs review
FileSize
24.74 KB
1.18 KB

This should fix the remaining tests.

dawehner’s picture

This migrate test is just a bit sad.

  1. +++ b/core/modules/dblog/src/Plugin/views/area/ClearLogForm.php
    @@ -0,0 +1,42 @@
    +  public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
    +    parent::init($view, $display, $options);
    +    $this->formBuilder = \Drupal::formBuilder();
    +  }
    

    Let's use the create method to inject it properly and also document this variable on the class

  2. +++ b/core/modules/dblog/src/Plugin/views/area/ClearLogForm.php
    @@ -0,0 +1,42 @@
    +      return $this->formBuilder->getForm('Drupal\dblog\Form\DblogClearLogForm');
    

    we could use ::class here

dawehner’s picture

Status: Needs review » Needs work
dagmar’s picture

Ok, new approach. Instead of implementing an area handler, lets implement a Exposed form. With this approach is possible to place the Clear log form at the bottom of the view.

Regarding the formBuilder I'm leaving this on purpose because this could be moved into another issue (There is another call in renderExposedForm) and we could unify and document it properly once #2642598: Create an interface for the public methods on ExposedFormPluginBase gets in.

Status: Needs review » Needs work

The last submitted patch, 39: replace_dblog_recent-2015149-39.patch, failed testing.

dagmar’s picture

Status: Needs work » Needs review
FileSize
24.69 KB
497 bytes

Adding schema for the dblog exposed form, not sure if this will fix the issue with the tests.

dagmar’s picture

Issue summary: View changes

Updated issue summary.

dagmar’s picture

Issue summary: View changes
Status: Needs review » Needs work

Clear logs button is not redirecting to the confirmation page.

dagmar’s picture

Status: Needs work » Needs review
FileSize
31.31 KB
8.48 KB

All tests for the default recent logs UI are now applied to the views version.

dagmar’s picture

Some final adjustments. I think this is now ready to go.

All the tests applied to the standard admin/reports/dblog are also run over the UI provided using views.

dagmar’s picture

dawehner’s picture

Issue tags: +Needs screenshots

Does someone mind posting an image of with and without views?

  1. +++ b/core/modules/dblog/src/Plugin/views/exposed_form/DblogForm.php
    @@ -0,0 +1,45 @@
    +    $log_form = \Drupal::formBuilder()->getForm('Drupal\dblog\Form\DblogClearLogForm', $form_state);
    

    You could use DblogClearLogForm::class

  2. +++ b/core/modules/dblog/src/Tests/DbLogTest.php
    @@ -502,7 +528,7 @@ public function testDBLogAddAndClear() {
    -    $this->drupalPostForm('admin/reports/dblog', array(), t('Clear log messages'));
    +    $this->clearLogsEntries();
    
    @@ -550,10 +576,7 @@ public function testFilter() {
    -      $edit = array(
    -        'type[]' => array($type_name),
    -      );
    -      $this->drupalPostForm(NULL, $edit, t('Filter'));
    +      $this->filterLogsEntries($type_name);
    

    I like those new methods!

dagmar’s picture

  1. Added screenshots. Fallback UI Views UI
  2. Added responsive support.
  3. Now using DblogClearLogForm::class
dawehner’s picture

Issue summary: View changes
dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Nice addition of the responsive classes!

dagmar’s picture

catch’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/dblog/src/Plugin/views/exposed_form/DblogForm.php
@@ -0,0 +1,46 @@
+
+/**
+ * Exposed form plugin that provides a Clear Logs button.
+ *
+ * @ingroup views_exposed_form_plugins
+ *
+ * @ViewsExposedForm(
+ *   id = "dblog_form",
+ *   title = @Translation("Dblog Form"),
+ *   help = @Translation("An exposed form to work when showing logs.")
+ * )
+ */

I understand this maintains feature parity, but it seems odd to me. I'd rather move it to a tab or something to avoid making it part of the views integration.

catch’s picture

Issue tags: +Needs usability review

Or it could be an action link to a confirm form instead of a tab.

Tagging for usability review.

yoroy’s picture

I think we should maintain the fieldset around the filter options. It's not really clear at the moment that the "Filter" button applies to the multi select boxes above. (Design principle: group related items)

We could merge the two fieldsets and provide the more standard red "Delete" link:

Maybe #2506449: Transform "Clear log messages" submit button into a link in admin/reports/dblog can be repurposed to do that.

yoroy’s picture

FileSize
68.97 KB
dagmar’s picture

Status: Needs work » Postponed
Issue tags: -Needs usability review

I posted a patch here #2506449: Transform "Clear log messages" submit button into a link in admin/reports/dblog that needs some code review. I'm deleting usability review tag since @yoroy already did a usability review there.

I'm setting this as postponed until that patch be committed, then I can provide a new patch here much more simple to review here.

catch’s picture

Status: Postponed » Needs work
dagmar’s picture

Status: Needs work » Needs review
FileSize
4.16 KB
26.04 KB

Here is the new patch without the ExposedForm plugins.

dagmar’s picture

Attached screenshots comparing the versions with Views and without Views.

dagmar’s picture

Status: Needs review » Needs work

The last submitted patch, 61: replace_dblog_recent-2015149-61.patch, failed testing.

dagmar’s picture

Status: Needs work » Needs review

That test pass locally for me.

dagmar’s picture

Someone would like to do a final review about this patch? @dawehner @damiankloip ?

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

dagmar’s picture

Re-rolled against 8.3.x.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

This looks simply nice for me

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/dblog/src/Tests/DbLogTest.php
@@ -807,7 +813,6 @@ public function testOverviewLinks() {
-    $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>");

Removing this assertion doesn't look right. It looks like it is there to provide a positive assertion with the assertNoRaw()

dagmar’s picture

Status: Needs work » Needs review
FileSize
694 bytes
29.63 KB

Well I removed that assertion because views trim sightly different strings and that assertion didn't pass using the full text. Lets try with this approach.

Status: Needs review » Needs work

The last submitted patch, 69: replace_dblog_recent-2015149-69.patch, failed testing.

dagmar’s picture

Status: Needs work » Needs review
FileSize
26.66 KB

Sorry I included the code from another issue in the same patch.

Status: Needs review » Needs work

The last submitted patch, 71: replace_dblog_recent-2015149-71.patch, failed testing.

dagmar’s picture

Status: Needs work » Needs review
FileSize
602 bytes
26.66 KB

Rerolled.

Lendude’s picture

--- /dev/null
+++ b/core/modules/dblog/config/optional/views.view.watchdog.yml

@@ -115,3 +115,12 @@ function dblog_form_system_logging_settings_alter(&$form, FormStateInterface $fo
+  if ($form['#id'] == 'views-exposed-form-watchdog-page') {

I never like using #id here, since it can be validly altered by previous form alter calls, I think $form_state->get('view')->id() == 'watchdog' is more robust.

And don't we want some sort of update path for this? I'd love to have this in my existing sites without having to manually import it, but I'm fine with a follow up for that if people agree this would be a 'nice to have'

Other then that, this looks great to me and all feedback in previous issues has been addressed.

dagmar’s picture

Thanks @Lendude here is the new patch with your suggestions.

Lendude’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/dblog/dblog.install
    @@ -90,3 +93,19 @@ function dblog_schema() {
    +function dblog_update_8300() {
    

    I think config changes are usually done in post_update hooks (see views.post_update.php for some examples)

  2. +++ b/core/modules/dblog/dblog.install
    @@ -90,3 +93,19 @@ function dblog_schema() {
    +  if (!View::load('watchdog') && \Drupal::moduleHandler()->moduleExists('views')) {
    ...
    +  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");
    

    I think this needs all needs to be inside an if (\Drupal::moduleHandler()->moduleExists('views')) or users will see this message when views isn't actually installed. Which would be confusing.

    Also the order of the calls in if (!View::load('watchdog') && \Drupal::moduleHandler()->moduleExists('views')) should probably be the other way around. But that should be resolved too if you move the \Drupal::moduleHandler()->moduleExists('views') call to a higher level if()

dagmar’s picture

Status: Needs work » Needs review
FileSize
27.86 KB
1.58 KB

Thanks @Lendude. I tried to use the dblog.post_update.php without luck, the only way I could ran the updates was using hook_update_N.

Applied the other suggestions.

Lendude’s picture

@dagmar this post_update works for me.

Status: Needs review » Needs work

The last submitted patch, 78: replace_dblog_recent-2015149-78.patch, failed testing.

Lendude’s picture

Status: Needs work » Needs review

Silly testbot saying it failed when it didn't!

jibran’s picture

Nice work this is almost ready just few observations.

  1. +++ b/core/modules/dblog/dblog.module
    @@ -115,3 +115,12 @@ function dblog_form_system_logging_settings_alter(&$form, FormStateInterface $fo
    +    $form['#attached'] = ['library' => ['dblog/drupal.dblog']];
    

    This should be $form['#attached']['library'][] = 'dblog/drupal.dblog';. We don't want to overwrite the existing values.

  2. +++ b/core/modules/dblog/dblog.post_update.php
    @@ -0,0 +1,31 @@
    +function dblog_post_update_convert_recent_messages_to_view() {
    

    We need an upgrade path test for this.

  3. +++ b/core/modules/dblog/dblog.post_update.php
    @@ -0,0 +1,31 @@
    +      $config_path = drupal_get_path('module', 'dblog') . '/config/optional/views.view.watchdog.yml';
    +      $data = Yaml::parse($config_path);
    +      \Drupal::configFactory()->getEditable('views.view.watchdog')->setData($data)->save(TRUE);
    

    Instead of doing this we should do it like this.

      // Save the watchdog view to config.
      $optional_install_path = $module_handler->getModule('dblog')->getPath() . '/' . InstallStorage::CONFIG_OPTIONAL_DIRECTORY;
      $storage = new FileStorage($optional_install_path);
      $entity_type_manager
        ->getStorage('view')
        ->create($storage->read('views.view.watchdog'))
        ->save();
    
dagmar’s picture

Status: Needs review » Needs work

Thanks for your feedback!

dagmar’s picture

Status: Needs work » Needs review
FileSize
50.44 KB
24.25 KB

1, 2 and 3 fixed. Let see what the test bot says.

Status: Needs review » Needs work

The last submitted patch, 83: replace_dblog_recent-2015149-83.patch, failed testing.

dagmar’s picture

Status: Needs work » Needs review
FileSize
50.49 KB
708 bytes

Status: Needs review » Needs work

The last submitted patch, 85: replace_dblog_recent-2015149-85.patch, failed testing.

dagmar’s picture

Status: Needs work » Needs review
FileSize
50.49 KB
431 bytes

Status: Needs review » Needs work

The last submitted patch, 87: replace_dblog_recent-2015149-87.patch, failed testing.

dagmar’s picture

Status: Needs work » Needs review
Issue tags: -Needs upgrade path tests
FileSize
714 bytes
50.5 KB

Status: Needs review » Needs work

The last submitted patch, 89: replace_dblog_recent-2015149-89.patch, failed testing.

dagmar’s picture

Status: Needs work » Needs review
yoroy’s picture

Thank you @dagmar for staying on the case here. Hope this makes it in soon now!

Lendude’s picture

Status: Needs review » Needs work

Almost there I think.

+++ b/core/modules/dblog/src/Tests/Update/DblogRecentLogsUsingViewsUpdateTest.php
@@ -0,0 +1,36 @@
+      __DIR__ . '/../../../tests/fixtures/update/drupal-8.replace-recent-log-with-a-view-2015149.php',

This needs to be taken out. Along with the two files in fixtures. The way I read it, a watchdog View is now being added before running the updates and then a check is done if it exists after running updates. If you change the update test to:

public function testUpdate() {
    $view = \Drupal::entityTypeManager()->getStorage('view')->load('watchdog');
    $this->assertNull($view);

    $this->runUpdates();

    // Get particular view.
    $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.');
  }

The test actually fails because the View already exists before ->runUpdates().

So my suggestion would be to take that out and add the assertNull, it's always good to test 'before' and 'after' states.

dagmar’s picture

Status: Needs work » Needs review
FileSize
22.67 KB
29.54 KB

Well, that makes totally sense :). Thanks!

dagmar’s picture

Lendude’s picture

Status: Needs review » Reviewed & tested by the community

We have tests, we have an upgrade path, we have an upgrade path test. I think this is ready.

@dagmar++

jibran’s picture

Thanks for addressing the feedback @dagmar. Nice work on the upgrade path and tests. @Lendude++ for awesome feedback in #93. RTBC++. Just a minor concern related to post update vs update_N hook here but I think @catch or @alexpott can make it clearer before the commit.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 95: replace_dblog_recent-2015149-95.patch, failed testing.

Lendude’s picture

Status: Needs work » Reviewed & tested by the community

Unrelated fail in Drupal\locale\Tests\LocaleUpdateTest.

dagmar’s picture

Just a minor concern related to post update vs update_N hook here but I think @catch or @alexpott can make it clearer before the commit.

I would like to know if this will require a change @catch @alexpot could you clarify that? This issue has been ready for almost 2 weeks and we don't have much more time to put in into 8.3.x.

dawehner’s picture

I think a post update is fine here. The system is in a working state before running that particular update.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

dagmar’s picture

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

I've tested view and update manually. All looks good. A post update is fine. I've backported this to 8.3.x because I see little risk in doing.

Committed and pushed 5987dac to 8.4.x and e2a87a2 to 8.3.x. Thanks!

diff --git a/core/modules/dblog/dblog.post_update.php b/core/modules/dblog/dblog.post_update.php
index 5c60294..d3ffdff 100644
--- a/core/modules/dblog/dblog.post_update.php
+++ b/core/modules/dblog/dblog.post_update.php
@@ -1,5 +1,10 @@
 <?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;
diff --git a/core/modules/dblog/src/Tests/DbLogViewsTest.php b/core/modules/dblog/src/Tests/DbLogViewsTest.php
index 52d4d52..53284ca 100644
--- a/core/modules/dblog/src/Tests/DbLogViewsTest.php
+++ b/core/modules/dblog/src/Tests/DbLogViewsTest.php
@@ -66,4 +66,5 @@ public function testDBLogAddAndClear() {
 
     parent::testDBLogAddAndClear();
   }
+
 }

Some coding standards fixes.

  • alexpott committed 5987dac on 8.4.x
    Issue #2015149 by dagmar, Pol, Lendude, damiankloip, alansaviolobo,...

  • alexpott committed e2a87a2 on 8.3.x
    Issue #2015149 by dagmar, Pol, Lendude, damiankloip, alansaviolobo,...
alexpott’s picture

Issue tags: +Needs change record

Looking at the existing CR https://www.drupal.org/node/2084727 - I actually think that this could do with it's own since it has been so long and using the same CR feels wrong since you can't set the release correctly.

alexpott’s picture

Issue tags: +8.3.0 release notes
dawehner’s picture

Nice work!

alesr’s picture

Nice to see that patch finally coming to D8.
Great work!

dagmar’s picture

Issue tags: -Needs change record

Change record added here, still in draft for a review: https://www.drupal.org/node/2850115

dagmar’s picture

  • alexpott committed f5d91e6 on 8.3.x
    Revert "Issue #2015149 by dagmar, Pol, Lendude, damiankloip,...

  • alexpott committed f6c8f90 on 8.4.x
    Revert "Issue #2015149 by dagmar, Pol, Lendude, damiankloip,...
alexpott’s picture

Status: Fixed » Needs work

Tasks shouldn't be introducing bugs in the alpha stage of a release. Revert thing change to fix #2849797: dblog link broken with > 1000 watchdog entries. Also we need to ensure that the default behaviour when creating a view on log entries does not add a wid column with a thousand separator since that is exactly what happens atm.

alexpott’s picture

I think both the uid and wid columns defined in dblog_views_data() should have the type of standard and not numeric.

alexpott’s picture

In fact perhaps we're going to need to fix #115/#116 in a separate issue first since that is going to need a hook_update_N to fix existing views. :( - glad we found this before 8.3.x though.

alexpott’s picture

In fact reviewing this change again I think we should split out all the changes to dblog_views_data() since I think we need to provide an upgrade path for some of them. For example:

+++ b/core/modules/dblog/dblog.views.inc
@@ -120,7 +128,7 @@ function dblog_views_data() {
-      'options callback' => 'Drupal\dblog\Controller\DbLogController::getLogLevelClassMap',
+      'options callback' => 'Drupal\Core\Logger\RfcLogLevel::getLevels',

If they've set some defaults on an existing view - isn't it now broken?

Plus the uid ought to use the user_name filter cause then it'd get auto-complete if you exposed it.

dagmar’s picture

Status: Needs work » Needs review
FileSize
29.43 KB
1.95 KB

Thanks @alexpott here is the new patch with the fixes.

+++ b/core/modules/dblog/dblog.views.inc
@@ -120,7 +128,7 @@ function dblog_views_data() {
- 'options callback' => 'Drupal\dblog\Controller\DbLogController::getLogLevelClassMap',
+ 'options callback' => 'Drupal\Core\Logger\RfcLogLevel::getLevels',
If they've set some defaults on an existing view - isn't it now broken?

Actually they don't. They are indexed by id like this:

    [7] => dblog-debug
    [6] => dblog-info
    [5] => dblog-notice
    [4] => dblog-warning
    [3] => dblog-error
    [2] => dblog-critical
    [1] => dblog-alert
    [0] => dblog-emergency

So if you have some defaults, views internally stores the ID of the log level. The only thing that actually changes is the order in the exposed filter and the use of human descriptions instead of machine names.

Addressed the other items in this patch.

alexpott’s picture

Status: Needs review » Needs work

@dagmar but the problem is that the uid and wid fields in dblog_views_data() shouldn't be numeric - there never is a occasion where a thousand separator is appropriate. For either field. Plus uid should be using the user_name filter.

dagmar’s picture

Status: Needs work » Needs review
FileSize
29.75 KB
2.72 KB

Thanks @alexpott now I see what you mean.

Status: Needs review » Needs work

The last submitted patch, 121: replace_dblog_recent-2015149-121.patch, failed testing.

dagmar’s picture

Status: Needs work » Needs review
FileSize
855 bytes
29.57 KB

Removing the last failing tests now that we don't have the separator anymore.

dagmar’s picture

Status: Needs review » Reviewed & tested by the community

Sorry, moving again this to RTBC to get @alexpott attention. The functionality provided by patch #123 is the same than committed on #113

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Sorry it appears my original commit was premature.

+++ b/core/modules/dblog/dblog.views.inc
@@ -20,11 +20,19 @@ function dblog_views_data() {
+  $data['watchdog']['table']['join'] = array(
+    // Link ourselves to the {users_field_data} table
+    'users_field_data' => array(
+      'field' => 'uid',
+      'left_field' => 'uid',
+    ),
+  );
+
   $data['watchdog']['wid'] = array(
     'title' => t('WID'),
     'help' => t('Unique watchdog event ID.'),
     'field' => array(
-      'id' => 'numeric',
+      'id' => 'standard',
     ),
     'filter' => array(
       'id' => 'numeric',
@@ -39,12 +47,11 @@ function dblog_views_data() {

@@ -39,12 +47,11 @@ function dblog_views_data() {
 
   $data['watchdog']['uid'] = array(
     'title' => t('UID'),
-    'help' => t('The user ID of the user on which the log entry was written..'),
     'field' => array(
-      'id' => 'numeric',
+      'id' => 'standard',
     ),
     'filter' => array(
-      'id' => 'numeric',
+      'id' => 'user_name',
     ),
     'argument' => array(
       'id' => 'numeric',
@@ -52,7 +59,7 @@ function dblog_views_data() {

@@ -52,7 +59,7 @@ function dblog_views_data() {
     'relationship' => array(
       'title' => t('User'),
       'help' => t('The user on which the log entry as written.'),
-      'base' => 'users',
+      'base' => 'users_field_data',
       'base field' => 'uid',
       'id' => 'standard',
     ),
@@ -120,7 +127,7 @@ function dblog_views_data() {

@@ -120,7 +127,7 @@ function dblog_views_data() {
     ),
     'filter' => array(
       'id' => 'in_operator',
-      'options callback' => 'Drupal\dblog\Controller\DbLogController::getLogLevelClassMap',
+      'options callback' => 'Drupal\Core\Logger\RfcLogLevel::getLevels',
     ),
     'sort' => array(
       'id' => 'standard',
diff --git a/core/modules/dblog/src/Tests/DbLogTest.php b/core/modules/dblog/src/Tests/DbLogTest.php

As stated earlier I think this needs to go in another issue because I think this needs an upgrade path for existing dblog views.

+++ b/core/modules/dblog/dblog.module
@@ -115,3 +115,12 @@ function dblog_form_system_logging_settings_alter(&$form, FormStateInterface $fo
+/**
+ * Implements hook_form_FORM_ID_alter().
+ */
+function dblog_form_views_exposed_form_alter(&$form, FormStateInterface $form_state) {
+  if ($form_state->get('view')->id() == 'watchdog') {
...
+  }
+}

Looking at this again I'm not sure we should be doing this like this. If you remove the exposed form you'd lose the icons - that's weird. hook_views_pre_render() is a better choice. See views_test_data_views_pre_render() for an example.

dagmar’s picture

Status: Needs work » Needs review
FileSize
30.32 KB
2.03 KB

Thanks @alexpott

As stated earlier I think this needs to go in another issue because I think this needs an upgrade path for existing dblog views.

This patch removes all the controversial modifications to the dblog.views.inc file which makes the upgrade path non required. Let me elaborate:

  • The uid filter remains numeric. This is for 3 reasons. First, if an existing view is using this filter and is converted to user_name it will break really bad, specially if the filter has some predefined values. The upgrade path is not easy (or economic) to code and probably will not add real value. In second place, users may still want to filter by numeric ids, for example logs created by specific users (uid < 10). And third, site administrators can use the Autocomplete user name widget by selecting 'name' after adding the relationship. Which is what this patch do.
  • The current relationship provided by dblog is useless. If you select it, only allows you to filter by UUID and Language code of the user. With the new relationship you still have those filters plus all the useful values like name, created time, etc. No upgrade path needed here then either.
  • For wid and type, the standard field handler works out of the box after rebuild the registry.
  • Regarding the type filter change, as I explained on #119 the values stored are numeric and they work just fine after the upgrade. In fact the exported version of a view with some selected values on the servery filter looks like this for both scenarios:
          filters:
            severity:
              id: severity
              table: watchdog
              field: severity
              operator: in
              value:
                1: '1'
                4: '4'
    

Please don't see explanation as an act of laziness, I spent 2 hours finding an elegant way to write an upgrade path and another 2 doing several tests to ensure this stills works after upgrade.

Looking at this again I'm not sure we should be doing this like this. If you remove the exposed form you'd lose the icons - that's weird. hook_views_pre_render() is a better choice. See views_test_data_views_pre_render() for an example.

Great suggestion! I adapted the code to apply the styles to all views that use the watchdog as base table, so we can have icons in several views that shows logs.

dagmar’s picture

Assigned: Unassigned » dagmar

Although no upgrade path is needed, this should be able to be tested. The upgrade path is simple rebuild the registry. I will work on the upgrade path test.

dagmar’s picture

Status: Needs review » Postponed
xjm’s picture

Issue tags: -8.3.0 release notes

Thanks @dagmar.

dagmar’s picture

Assigned: dagmar » Unassigned
Status: Postponed » Needs work

#2851293: dblog is using the wrong views field, filter and relationships definitions was committed and pushed to 8.4.x. We can continue working on this issue now. I would like to see others continue this patch so I can review it as new dblog maintainer.

dagmar’s picture

Issue summary: View changes
Issue tags: +Needs reroll
pritish.kumar’s picture

Status: Needs work » Needs review
FileSize
36.67 KB

Uploading the reroll patch.

There are 2 changes which were present in the most recent patch which I have not applied.

diff --git a/core/modules/migrate_drupal_ui/src/Tests/d6/MigrateUpgrade6Test.php b/core/modules/migrate_drupal_ui/src/Tests/d6/MigrateUpgrade6Test.php
index 50829f0..8e1f3ab 100644
--- a/core/modules/migrate_drupal_ui/src/Tests/d6/MigrateUpgrade6Test.php
+++ b/core/modules/migrate_drupal_ui/src/Tests/d6/MigrateUpgrade6Test.php
@@ -63,7 +63,7 @@ protected function getEntityCounts() {
'user' => 7,
'user_role' => 6,
'menu_link_content' => 4,
- 'view' => 12,
+ 'view' => 13,
'date_format' => 11,
'entity_form_display' => 15,
'entity_form_mode' => 1,
diff --git a/core/modules/migrate_drupal_ui/src/Tests/d7/MigrateUpgrade7Test.php b/core/modules/migrate_drupal_ui/src/Tests/d7/MigrateUpgrade7Test.php
index 77bc2ab..99b29ee 100644
--- a/core/modules/migrate_drupal_ui/src/Tests/d7/MigrateUpgrade7Test.php
+++ b/core/modules/migrate_drupal_ui/src/Tests/d7/MigrateUpgrade7Test.php
@@ -64,7 +64,7 @@ protected function getEntityCounts() {
'user' => 4,
'user_role' => 3,
'menu_link_content' => 7,
- 'view' => 12,
+ 'view' => 13,
'date_format' => 11,
'entity_form_display' => 16,
'entity_form_mode' => 1,

Status: Needs review » Needs work

The last submitted patch, 132: replace_dblog_recent-2015149-132.patch, failed testing.

pritish.kumar’s picture

Status: Needs work » Needs review
FileSize
28.78 KB

Status: Needs review » Needs work

The last submitted patch, 134: replace_dblog_recent-2015149-134.patch, failed testing.

dagmar’s picture

  1. +++ b/core/modules/dblog/dblog.module
    @@ -101,7 +102,7 @@ function dblog_form_system_logging_settings_alter(&$form, FormStateInterface $fo
    -    '#options' => [0 => t('All')] + array_combine($row_limits, $row_limits),
    +    '#options' => [0 => t('All')]  array_combine($row_limits, $row_limits),
    

    This is the problem reported by the automated test system.

  2. +++ b/core/modules/dblog/dblog.views.inc
    @@ -19,6 +19,13 @@ function dblog_views_data() {
    +  $data['watchdog']['table']['join'] = array(
    +    // Link ourselves to the {users_field_data} table
    +    'users_field_data' => array(
    +    'field' => 'uid',
    +    'left_field' => 'uid',
    +    ),
    +  );
    

    This should not be included in this patch.

+++ b/core/modules/dblog/dblog.post_update.php
@@ -0,0 +1,44 @@
diff --git a/core/modules/dblog/dblog.views.inc b/core/modules/dblog/dblog.views.inc

diff --git a/core/modules/dblog/dblog.views.inc b/core/modules/dblog/dblog.views.inc
index 6ad9e68..634bd09 100644

index 6ad9e68..634bd09 100644
--- a/core/modules/dblog/dblog.views.inc

--- a/core/modules/dblog/dblog.views.inc
+++ b/core/modules/dblog/dblog.views.inc

+++ b/core/modules/dblog/dblog.views.inc
+++ b/core/modules/dblog/dblog.views.inc
@@ -1,4 +1,4 @@

@@ -1,4 +1,4 @@
-<?php
+  <?php

This file should not be modified

jofitz’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
5.7 KB
29.01 KB

Corrections to the reroll.

dagmar’s picture

Status: Needs review » Needs work

Thanks!

  1. +++ b/core/modules/dblog/dblog.post_update.php
    @@ -0,0 +1,44 @@
    +/**
    + * @addtogroup updates-8.3.x
    + * @{
    + */
    

    This should be removed.

  2. +++ b/core/modules/dblog/dblog.post_update.php
    @@ -0,0 +1,44 @@
    +/**
    + * @} End of "addtogroup updates-8.3.x".
    + */
    

    This should be removed.

  3. +++ b/core/modules/dblog/dblog.views.inc
    @@ -20,6 +20,14 @@ function dblog_views_data() {
    +  $data['watchdog']['table']['join'] = [
    +    // Link ourselves to the {users_field_data} table
    +    'users_field_data' => [
    +      'field' => 'uid',
    +      'left_field' => 'uid',
    +    ],
    +  ];
    

    This is not necessary anymore.

  4. +++ b/core/modules/dblog/tests/modules/dblog_test_views/test_views/views.view.test_dblog.yml
    @@ -37,7 +37,7 @@ display:
    -          plugin_id: numeric
    +          plugin_id: standard
    

    This is not necessary. We have update functions that take care about this.

  5. +++ b/core/modules/dblog/src/Tests/DbLogViewsTest.php
    @@ -0,0 +1,70 @@
    +class DbLogViewsTest extends DbLogTest {
    

    Technically new tests should be BTB test now. But we didn't upgrade dblog tests yet. I think is ok to convert them in: #2863372: Convert dblog web tests to BrowserTestBase

jofitz’s picture

Status: Needs work » Needs review
FileSize
1.98 KB
27.7 KB
  1. Removed.
  2. Removed.
  3. Removed.
  4. Reverted.
  5. Leaving as-is.
dagmar’s picture

Status: Needs review » Needs work
FileSize
1.33 KB

Sorry I missed this line:

+++ b/core/modules/dblog/config/optional/views.view.watchdog.yml
@@ -0,0 +1,712 @@
+          plugin_id: in_operator

This should be using the new dblog_types plugin.

I tried the patch using a 8.3.x code with 2000 logs, ran the upgrade path and checked that all work as expected. The only difference between the original log listing and the view listing is the pager that is using a mini pager.

So change the pager from mini to full and the filter plugin from in_operator to dblog_types and this will be ready to be committed.

Attaching the expected interdiff for the next patch.

jibran’s picture

dagmar’s picture

According to #1909474: Use light (lite) pager by default all core listings are now using minipagers. So agree with jibran. Lets keep the mini pager for logs too. Users can configure it to use the full pager if they need it.

The filter plugin change is still required though.

dagmar’s picture

Issue summary: View changes

Updated the issue summary to reflect the remaining work needed here.

nicolas.rafaelli’s picture

Status: Needs work » Needs review
FileSize
27.7 KB
565 bytes

Hope this help

dagmar’s picture

Issue summary: View changes
Status: Needs review » Needs work
FileSize
43.06 KB

This is looking really good. There is a small problem in mobile though. All the columns of the view are hidden.

The seems to be:

            message:
              sortable: false
              default_sort_order: asc
              align: ''
              separator: ''
              empty_column: false
              responsive: priority-medium

Responsive should be set to ''

            message:
              sortable: false
              default_sort_order: asc
              align: ''
              separator: ''
              empty_column: false
              responsive: ''

Also, Severity Level in the exposed filter should be renamed to Severity

hanoii’s picture

Status: Needs work » Needs review
FileSize
27.92 KB
1.09 KB

Attached is the patch with that sorted and the interdiff. The responsive fix was set to priority-high instead of ''.

Status: Needs review » Needs work

The last submitted patch, 146: 2015149-146.patch, failed testing.

hanoii’s picture

Status: Needs work » Needs review
FileSize
27.73 KB
1.09 KB

Sorry, proper patch now, forgot to `git pull` :s.

dagmar’s picture

Status: Needs review » Reviewed & tested by the community

Thanks everyone!.

I ran the following tests.

  • Upgrade from 8.3.x to 8.4.x.
  • Installed from scratch in 8.4.x.
  • Checked the mobile and desktop functionality.
  • Tested with more than 1000 logs, which was the original cause of the revert.
  • Disabling and enabling views to check the previous version still works.

Due the fact all the the tests applied to the default list are applied to the view too. I think this is now ready to go.

dagmar’s picture

Issue summary: View changes
catch’s picture

+++ b/core/modules/dblog/dblog.post_update.php
@@ -0,0 +1,35 @@
+
+/**
+ * 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");
+  }
+}

Do we really want to do enable the view in an update? This is a good case for a 'choose-your-own-adventure' update where we can give people a choice whether to do it or not, but we don't have the infrastructure for that yet. We could also defer the update to a follow-up and have this discussion there maybe.

+++ b/core/modules/dblog/src/Tests/DbLogViewsTest.php
@@ -0,0 +1,70 @@
+    $query = [];
+    if (!is_null($type)) {
+      $query['type[]'] = $type;
+    }
+    if (!is_null($severity)) {
+      $query['severity[]'] = $severity;
+    }
+

Why not isset() here? Not sure the specificity of is_null() helps at all.

catch’s picture

Status: Reviewed & tested by the community » Needs review
dagmar’s picture

Do we really want to do enable the view in an update? This is a good case for a 'choose-your-own-adventure' update where we can give people a choice whether to do it or not, but we don't have the infrastructure for that yet. We could also defer the update to a follow-up and have this discussion there maybe.

I think is better to have an update that actually warn you this is going to be enabled (and you can disable it later) rather than make this optional, which actually is not optional at all because if you install dblog and views is enabled, the default view will be activated by default without asking you if you want to avoid it.

Why not isset() here? Not sure the specificity of is_null() helps at all.

This is how is currently implemented in filterLogsEntries() I tried to make this as transparent to review. There are a lot of things to improve in the DblogTest that are tracked in other issues. (#2882525: Move suspicious string in DblogTest into a KernelTest, #2848529: Move DbLogTest::verifyCron to a kernel test, #2863372: Convert dblog web tests to BrowserTestBase)

dagmar’s picture

Issue summary: View changes
Status: Needs review » Needs work

Ok. I think Why not isset() here? Not sure the specificity of is_null() helps at all. can be fixed here. I still think this have to enable the view using an update.

dagmar’s picture

Issue summary: View changes

Since #2863372: Convert dblog web tests to BrowserTestBase was committed. Now is necessary to modify from which base class is extending the test for views.

dagmar’s picture

Status: Needs review » Needs work

The last submitted patch, 156: 2015149-156.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

dagmar’s picture

Status: Needs work » Needs review
FileSize
28.33 KB
606 bytes

This patch is a few kb smaller because the DbLogViewsTest.php was duplicated in the previous patch.

  • catch committed c99c526 on 8.4.x
    Issue #2015149 by dagmar, Jo Fitzgerald, hanoii, pritish.kumar, Pol,...
catch’s picture

Status: Needs review » Fixed

That's a fair point on the update, disabling the view is easier than re-creating from scratch, and it's admin-facing only.

Committed/pushed to 8.4.x, thanks!

ummm just realised this was at code needs review, for some reason I thought it was back to RTBC. Since it was a re-roll and one-line change from the previously RTBC patch, going to leave it in I think, but just owning up to the mistake...

  • catch committed f2d177a on 8.4.x
    Revert "Issue #2015149 by dagmar, Jo Fitzgerald, hanoii, pritish.kumar,...
catch’s picture

Status: Fixed » Needs review

Meh reverted, but if someone reviews and is happy with it I'll try to re-review/commit fairly quickly to make up for the false alarm.

mondrake’s picture

Status: Needs review » Needs work

Looked at it live in the interim phase between commit and revert :)

The two things that jump to my eyes:

  1. +++ b/core/modules/dblog/config/optional/views.view.watchdog.yml
    @@ -0,0 +1,712 @@
    +      sorts:
    +        timestamp:
    +          id: timestamp
    +          table: watchdog
    +          field: timestamp
    +          order: DESC
    +          entity_type: null
    +          entity_field: null
    +          plugin_id: date
    +          relationship: none
    +          group_type: group
    +          admin_label: ''
    +          exposed: false
    +          expose:
    +            label: ''
    +          granularity: second
    

    Sorting by 'timestamp' descending is confusing if you have multiple entries at the same clock time (happens a lot in development...). I think it would be better to sort by 'wid' descending to to ensure entries are shown in the proper sequence.

  2. +++ b/core/modules/dblog/tests/src/Functional/DbLogViewsTest.php
    @@ -0,0 +1,70 @@
    +    parent::testDBLogAddAndClear();
    +  }
    +
    +}
    \ No newline at end of file
    

    no newline

dagmar’s picture

Status: Needs work » Needs review
FileSize
28.2 KB
1.39 KB

Thanks @mondrake and @catch.

mondrake’s picture

Status: Needs review » Reviewed & tested by the community

Go @catch go 😀 (Re #162)

mondrake’s picture

Status: Reviewed & tested by the community » Needs work

Actually no, sorry, I think that the change in #164 for sorting is not enough.

It seems like the table format ordering overrides whatever 'sort criteria' are defined, i.e. the

+++ b/core/modules/dblog/config/optional/views.view.watchdog.yml
@@ -0,0 +1,709 @@
+            wid:
+              sortable: false
+              default_sort_order: asc
+              align: ''
+              separator: ''
+              empty_column: false
+              responsive: priority-low

part should also be set to 'sortable: true', 'default_sort_order: desc' and

+++ b/core/modules/dblog/config/optional/views.view.watchdog.yml
@@ -0,0 +1,709 @@
+          default: timestamp

to be set to 'default: wid'

mondrake’s picture

BTW: I double checked - the header specifying the sorting sequence in orderByHeader in the legacy DbLogController is

    $header = [
      // Icon column.
      '',
      [
        'data' => $this->t('Type'),
        'field' => 'w.type',
        'class' => [RESPONSIVE_PRIORITY_MEDIUM]],
      [
        'data' => $this->t('Date'),
        'field' => 'w.wid',
        'sort' => 'desc',
        'class' => [RESPONSIVE_PRIORITY_LOW]],
      $this->t('Message'),
      [
        'data' => $this->t('User'),
        'field' => 'ufd.name',
        'class' => [RESPONSIVE_PRIORITY_MEDIUM]],
      [
        'data' => $this->t('Operations'),
        'class' => [RESPONSIVE_PRIORITY_LOW]],
    ];

just confirming that currently sorting is by 'wid' descending.

mondrake’s picture

FileSize
19 KB

Uploading an export of the watchdog view after changes I made along #166 - works for me. Hope it can help.

dagmar’s picture

Thanks @mondrake. You are right, and actually this means lack of test coverage.

I added the modifications you mentioned and more test coverage to ensure this is working as expected.

mondrake’s picture

Can we blank out the 'sorts' section? it is irrelevant as the table format ordering overrides it and bad UX, a non experienced user will change it with nothing happening

dagmar’s picture

Can we blank out the 'sorts' section? it is irrelevant as the table format ordering overrides it and bad UX, a non experienced user will change it with nothing happening

No, because the default view also allow to sort by those values. Let's defer a full UX of the listing for other ticket. The objective of this ticket is to provide the same functionality we have currently but with a view.

Status: Needs review » Needs work

The last submitted patch, 169: 2015149-169-test-only.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

dagmar’s picture

Status: Needs work » Needs review
mondrake’s picture

Status: Needs review » Reviewed & tested by the community

Ok then, RTBC. There's a small code style issue as identified by codesniffer, but it can be fixed on commit if @catch agrees.

  • catch committed b1e2ed5 on 8.4.x
    Issue #2015149 by dagmar, Jo Fitzgerald, hanoii, pritish.kumar, Pol,...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Good catch on the sort and thanks for the additional test coverage.

Fixed the code style issue on commit.

FILE: .../Sites/8.x/core/modules/dblog/tests/src/Functional/DbLogTest.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 836 | ERROR | [x] The closing brace for the class must have an empty
     |       |     line before it
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

Committed/pushed to 8.4.x, thanks!

dagmar’s picture

Issue tags: +8.4.0 release notes

Thanks everyone. I published the change record.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

scarletdrupal123’s picture

It is very difficult to read the error message by going to database downloading blob file and then reading it , in case website has broken. Still not able to fix the issue in my website.