diff --git a/Koha/Database/Auditor.pm b/Koha/Database/Auditor.pm index fd01ac4be8..cd78db36e6 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 2d9419fd45..afb58e9555 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 9b5692c18a..67dc6a4a70 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 %]
- These commands are only suggestions! They are not a replacement for updatedatabase.pl!
- Review the database, updatedatabase.pl, and kohastructure.sql before making any changes!
-
Run the following SQL to fix the database:
-
- [% audit_diff | $raw %]
-
+ [% ELSE %]
+ [% db_audit.message | html %]
Run the following SQL to fix the database:
+
+ [% db_audit.diff | $raw %]
+
+