We found useful to include status error reporting in one of our projects.

This patch is based on contrib module Expose Status Report

Applying patch (#6) will provide an new integer entry in the status dashboard client´s json file, so it can be used at the server side.

This field will provide an integer value with the total amount of errors found at status report admin page.

In order to render get the status reports server side, patching server side status_dasboard module is necessary. (See related Issue below)

Comments

Diego Balboa created an issue. See original summary.

diego balboa’s picture

StatusFileSize
new3.17 KB
diego balboa’s picture

diego balboa’s picture

Issue summary: View changes
bramdriesen’s picture

Version: 2.0.0-alpha1 » 2.0.x-dev
Status: Needs review » Needs work
+++ b/src/Controller/StatusDashboardClientController.php	(date 1673514953284)
@@ -91,6 +112,17 @@
+    foreach ($raw as $line) {
+      if (isset($line['severity']) && $line['severity'] > 1) {
+        $error_counter++;
+        break;
+      }
+    }

Is this correct? This would mean that the foreach stops after the first occurrence if I'm not mistaken. I think you want to remove the break or replace it with continue. And we only want errors larger as severity 1?

I guess it would also help to add a comment somewhere indicating what error corresponds to severity 1 or higher.

diego balboa’s picture

StatusFileSize
new3.26 KB
+    $error_counter = 0;
+    foreach ($raw as $line) {
+      //By default only errors (severity > 1) will trigger. Severity > 0 to tirgger both errors or warnings. 
+      if (isset($line['severity']) && $line['severity'] > 1) {
+        $error_counter++;
+      }
+    }

Yes, it was a late time omission mistake after swithcing from boolearn to counter.

#2 wont work.

Thank you for pointing it out.

I fixed it and added a comment as suggested.

diego balboa’s picture

Issue summary: View changes
diego balboa’s picture

Issue summary: View changes
diego balboa’s picture

Version: 2.0.x-dev » 2.0.0-alpha1
diego balboa’s picture

Version: 2.0.0-alpha1 » 2.x-dev
Status: Needs work » Needs review
bramdriesen’s picture

  1. +++ b/src/Controller/StatusDashboardClientController.php	(date 1673520108051)
    @@ -91,6 +112,17 @@
    +      //By default only errors (severity > 1) will trigger. Severity > 0 to tirgger both errors or warnings. ¶
    

    Small nit, but the comment does not follow the coding standards (there is a typo, a trailing space and it's too long). It should be something like this:

    // By default only errors (severity > 1) will trigger.
    // Severity > 0 to tigger both errors or warnings.
  2. +++ b/src/Controller/StatusDashboardClientController.php	(date 1673520108051)
    @@ -98,7 +130,8 @@
    +      'total_status_errors' => $error_counter
    

    Should have a trailing "," since it's an array and maybe the name "total_status_errors" would be better like "status_error_count" (singular) or simply "error_count".

It's okay if you don't want to fix this, I can do it when I commit it to the dev branch.

One additional question. Is there also a change needed on the "status_dashboard" module itself to show the added field? (I didn't dive into the code of that module yet as I only recently became a maintainer)

bramdriesen’s picture

Status: Needs review » Needs work
diego balboa’s picture

Thank you for your feedback and rapid response, its my first patch contribution, so i appreciate it.

I will upload the changes you suggested in the following hour or so.

Answering your question, this patch only makes the necessary changes in the client to make available the info server side. I´ve been currently working on the related patch for the server side module "status_dashboard".

Planing to finish it, create an issue and upload it for review today/tomorrow.

Also i will update this issue when both issues/patches are publish (server and client).

diego balboa’s picture

StatusFileSize
new3.26 KB

Corrections made, patch uploaded.

bramdriesen’s picture

Status: Needs work » Reviewed & tested by the community

Sure no problem :-) glad to help you make your first code contribution and help steer you in the right direction.

I think the patch looks good now. One minor nit but I won't bother you with that ;-) looking forward to your next issue on the dashboard module itself.

Extra tip for you, the old patch flow (.patch files) will be deprecated in the future in favour of GitLab merge requests and issue forks :-) you can read about that here if you like: https://www.drupal.org/docs/develop/git/using-git-to-contribute-to-drupa... feel free to use that on your next issue! The first time doing this might look complicated, but it's actually very easy to use.

diego balboa’s picture

diego balboa’s picture

Thnkx Bram for the tip, i have been reading it a couple of days ago, unfortunately i didnt have enough time to use GitLab merge method this time. It will be next one for sure.

diego balboa’s picture

Hello again, i have been using this patch (in conjunction with server side one) for 2 weeks now without any issue.

Would there be any possibility of integrating this module in a future release?

if so, i would be happy to help with it if needed.

carlitus’s picture

StatusFileSize
new3.16 KB

I've made a new patch for the last dev version (1 Feb), because the last patch didn't apply.

bramdriesen’s picture

Hi, I'll try to get this committed somewhere this week!

carlitus’s picture

Perfect, thanks!

w.drupal’s picture

At the patch from https://www.drupal.org/project/status_dashboard_client/issues/3332883#co...
a comma was missing after $container->get('request_stack')

     return new static(
       $container->get('extension.list.module'),
       $container->get('datetime.time'),
       $container->get('request_stack')
+      $container->get('renderer'),
+      $container->get('system.manager')
     );

Also I added some code style fixes.

bramdriesen’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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