Bugzilla – Attachment 175934 Details for
Bug 36039
The output of audit_database.pl should be accessible through the UI
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36039: (QA follow-up): Improve audit messages
Bug-36039-QA-follow-up-Improve-audit-messages.patch (text/plain), 5.05 KB, created by
Pedro Amorim
on 2024-12-24 13:14:34 UTC
(
hide
)
Description:
Bug 36039: (QA follow-up): Improve audit messages
Filename:
MIME Type:
Creator:
Pedro Amorim
Created:
2024-12-24 13:14:34 UTC
Size:
5.05 KB
patch
obsolete
>From c55d197a1115958a1d21d6f98363b4e7789fb857 Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Date: Tue, 24 Dec 2024 13:09:02 +0000 >Subject: [PATCH] Bug 36039: (QA follow-up): Improve audit messages > >Improve messages clarity. >Show success message if no schema diff was found from audit. >Code refactor to ensure the title+message shown in UI is the same as the one shown in CLI and are all translatable. >--- > Koha/Database/Auditor.pm | 24 ++++++++++++++++-- > about.pl | 4 +-- > .../intranet-tmpl/prog/en/modules/about.tt | 25 +++++++++++-------- > misc/maintenance/audit_database.pl | 12 +++------ > 4 files changed, 41 insertions(+), 24 deletions(-) > >diff --git a/Koha/Database/Auditor.pm b/Koha/Database/Auditor.pm >index fd01ac4be83..cd78db36e66 100644 >--- a/Koha/Database/Auditor.pm >+++ b/Koha/Database/Auditor.pm >@@ -51,7 +51,10 @@ sub new { > > =head3 run > >-Run the database audit with the given arguments, including the filename. >+Compares the current database schema with the expected schema from the >+`kohastructure.sql` file. Generates SQL commands to update the database schema >+if differences are found. Returns a hash reference containing the differences, >+a flag indicating if differences were found, a message, and a title. > > =cut > >@@ -74,7 +77,24 @@ sub run { > } > )->compute_differences->produce_diff_sql; > >- return $diff; >+ my $diff_found = 1; >+ my $message = __( >+ "These commands are only suggestions. They are not a replacement for the database update scripts run during installations and updates.\nReview the database, the atomic update files and the table definitions in kohastructure.sql before running any of the commands below:" >+ ); >+ my $title = __("Warning!"); >+ >+ if ( $diff =~ /No differences found/ ) { >+ $diff_found = 0; >+ $message = __("The installed database schema is correct."); >+ $title = __("All is well"); >+ } >+ >+ return { >+ diff => $diff, >+ diff_found => $diff_found, >+ message => $message, >+ title => $title, >+ }; > } > } > >diff --git a/about.pl b/about.pl >index 2d9419fd455..afb58e95556 100755 >--- a/about.pl >+++ b/about.pl >@@ -929,7 +929,7 @@ sub message_broker_check { > if ( $tab eq 'database' ) { > use Koha::Database::Auditor; > my $db_auditor = Koha::Database::Auditor->new(); >- my $audit_diff = $db_auditor->run; >- $template->param( audit_diff => $audit_diff ); >+ my $db_audit = $db_auditor->run; >+ $template->param( db_audit => $db_audit ); > } > output_html_with_http_headers $query, $cookie, $template->output; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt >index 9b5692c18a6..a0412157e63 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt >@@ -798,19 +798,22 @@ > [% BLOCK database_panel %] > [% WRAPPER tab_panel tabname= "database" bt_active = 1 %] > <h2>Database audit</h2> >+ [% IF db_audit.diff_found %] > <div class="alert alert-warning"> >- <h3>WARNING!!!</h3> >- <p> >- These commands are only suggestions! They are not a replacement for updatedatabase.pl!<br /> >- Review the database, updatedatabase.pl, and kohastructure.sql before making any changes!<br /> >- </p> >- </div> >- <div> >- <p>Run the following SQL to fix the database:</p> >- <pre> >- <code>[% audit_diff | $raw %]</code> >- </pre> >+ [% ELSE %] >+ <div class="alert alert-success"> >+ [% END %] >+ <h3><strong>[% db_audit.title %]</strong></h3> >+ <p><pre>[% db_audit.message %]</pre><p> > </div> >+ [% IF db_audit.diff_found %] >+ <div> >+ <p>Run the following SQL to fix the database:</p> >+ <pre> >+ <code>[% db_audit.diff | $raw %]</code> >+ </pre> >+ </div> >+ [% END %] > [% END # tab=database %] > [% END %] > >diff --git a/misc/maintenance/audit_database.pl b/misc/maintenance/audit_database.pl >index 2d821b692aa..f99bc899a94 100755 >--- a/misc/maintenance/audit_database.pl >+++ b/misc/maintenance/audit_database.pl >@@ -11,12 +11,6 @@ GetOptions( > "filename=s" => \$filename, > ) or die("Error in command line arguments\n"); > >-my $auditor = Koha::Database::Auditor->new( { filename => $filename } ); >-my $diff = $auditor->run; >- >-my $warning = "\n" >- . "WARNING!!!\n" >- . "These commands are only suggestions! They are not a replacement for updatedatabase.pl!\n" >- . "Review the database, updatedatabase.pl, and kohastructure.sql before making any changes!\n" . "\n"; >- >-print $diff . $warning; >+my $auditor = Koha::Database::Auditor->new( { filename => $filename } ); >+my $db_audit = $auditor->run; >+print $db_audit->{title} . "\n" . $db_audit->{message} . "\n" . ( $db_audit->{diff_found} ? $db_audit->{diff} : '' ); >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 36039
:
161892
|
162462
|
162463
|
166097
|
166098
|
166099
|
166155
|
166156
|
166157
|
169225
|
169226
|
169227
|
174403
|
174404
|
174405
|
175933
| 175934