View | Details | Raw Unified | Return to bug 36039
Collapse All | Expand All

(-)a/Koha/Database/Auditor.pm (-25 / +2 lines)
Lines 44-58 sub new { Link Here
44
    my ( $class, $params ) = @_;
44
    my ( $class, $params ) = @_;
45
    my $self = bless $params // {}, $class;
45
    my $self = bless $params // {}, $class;
46
    $self->{filename} = $params->{filename} // './installer/data/mysql/kohastructure.sql';
46
    $self->{filename} = $params->{filename} // './installer/data/mysql/kohastructure.sql';
47
    $self->{is_cli}   = $params->{is_cli};
48
    return $self;
47
    return $self;
49
}
48
}
50
49
51
=head3 run
50
=head3 run
52
51
53
Run the database audit with the given arguments, including the filename
52
Run the database audit with the given arguments, including the filename.
54
    and whether it is a command-line interface(CLI).
55
Returns $diff only if $is_cli is false. Else it just prints $diff.
56
53
57
=cut
54
=cut
58
55
Lines 60-68 sub run { Link Here
60
    my ( $self, $args ) = @_;
57
    my ( $self, $args ) = @_;
61
58
62
    if ( !-f $self->{filename} ) {
59
    if ( !-f $self->{filename} ) {
63
        unless ( $self->{is_cli} ) {
64
            return 'Database schema file not found';
65
        }
66
        die("Filename '$self->{filename}' does not exist\n");
60
        die("Filename '$self->{filename}' does not exist\n");
67
    }
61
    }
68
62
Lines 78-104 sub run { Link Here
78
            }
72
            }
79
        )->compute_differences->produce_diff_sql;
73
        )->compute_differences->produce_diff_sql;
80
74
81
        return $diff unless $self->{is_cli};
75
        return $diff;
82
        print $diff . $self->get_warning;
83
    }
76
    }
84
}
77
}
85
78
86
=head3 get_warning
87
88
Retrieve a warning message.
89
90
=cut
91
92
sub get_warning {
93
    my ($self) = @_;
94
95
    return
96
          "\n"
97
        . "WARNING!!!\n"
98
        . "These commands are only suggestions! They are not a replacement for updatedatabase.pl!\n"
99
        . "Review the database, updatedatabase.pl, and kohastructure.sql before making any changes!\n" . "\n";
100
}
101
102
=head3 _get_db
79
=head3 _get_db
103
80
104
Retrieves the database schema, removes auto-increment from the schema, and returns the modified schema.
81
Retrieves the database schema, removes auto-increment from the schema, and returns the modified schema.
(-)a/about.pl (-2 / +2 lines)
Lines 908-915 if ( $tab eq 'history' ) { Link Here
908
908
909
if ( $tab eq 'database' ) {
909
if ( $tab eq 'database' ) {
910
    use Koha::Database::Auditor;
910
    use Koha::Database::Auditor;
911
    my $db_auditor = Koha::Database::Auditor->new( { is_cli => 0 } );
911
    my $db_auditor = Koha::Database::Auditor->new();
912
    my $audit_diff = $db_auditor->run;
912
    my $audit_diff = $db_auditor->run;
913
    $template->param( audit_diff => $audit_diff, audit_warning => $db_auditor->get_warning );
913
    $template->param( audit_diff => $audit_diff );
914
}
914
}
915
output_html_with_http_headers $query, $cookie, $template->output;
915
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt (-13 / +21 lines)
Lines 36-59 Link Here
36
                    [% WRAPPER tab_item linktab = 1 tabname = "about" bt_active = tab == "about" %] <span>Server information</span> [% END %]
36
                    [% WRAPPER tab_item linktab = 1 tabname = "about" bt_active = tab == "about" %] <span>Server information</span> [% END %]
37
                    [% WRAPPER tab_item linktab = 1 tabname = "perl" bt_active = tab == "perl" %] <span>Perl modules</span> [% END %]
37
                    [% WRAPPER tab_item linktab = 1 tabname = "perl" bt_active = tab == "perl" %] <span>Perl modules</span> [% END %]
38
                    [% WRAPPER tab_item linktab = 1 tabname = "sysinfo" bt_active = tab == "sysinfo" %] <span>System information</span> [% END %]
38
                    [% WRAPPER tab_item linktab = 1 tabname = "sysinfo" bt_active = tab == "sysinfo" %] <span>System information</span> [% END %]
39
                    [% WRAPPER tab_item linktab = 1 tabname = "database" bt_active = tab == "database" %] <span>Database audit</span> [% END %]
39
                    [% WRAPPER tab_item linktab = 1 tabname = "team" bt_active = tab == "team" %] <span>Koha team</span> [% END %]
40
                    [% WRAPPER tab_item linktab = 1 tabname = "team" bt_active = tab == "team" %] <span>Koha team</span> [% END %]
40
                    [% WRAPPER tab_item linktab = 1 tabname = "licenses" bt_active = tab == "licenses" %] <span>Licenses</span> [% END %]
41
                    [% WRAPPER tab_item linktab = 1 tabname = "licenses" bt_active = tab == "licenses" %] <span>Licenses</span> [% END %]
41
                    [% WRAPPER tab_item linktab = 1 tabname = "translations" bt_active = tab == "translations" %] <span>Translations</span> [% END %]
42
                    [% WRAPPER tab_item linktab = 1 tabname = "translations" bt_active = tab == "translations" %] <span>Translations</span> [% END %]
42
                    [% WRAPPER tab_item linktab = 1 tabname = "history" bt_active = tab == "history" %] <span>Timeline</span> [% END %]
43
                    [% WRAPPER tab_item linktab = 1 tabname = "history" bt_active = tab == "history" %] <span>Timeline</span> [% END %]
43
                    [% WRAPPER tab_item linktab = 1 tabname = "dedications" bt_active = tab == "dedications" %] <span>Dedications</span> [% END %]
44
                    [% WRAPPER tab_item linktab = 1 tabname = "dedications" bt_active = tab == "dedications" %] <span>Dedications</span> [% END %]
44
                    [% WRAPPER tab_item linktab = 1 tabname = "database" bt_active = tab == "database" %] <span>Database audit</span> [% END %]
45
                [% END %]
45
                [% END %]
46
                [% WRAPPER tab_panels %]
46
                [% WRAPPER tab_panels %]
47
                    [% SWITCH tab %]
47
                    [% SWITCH tab %]
48
                        [% CASE 'about' %] [% PROCESS about_panel %]
48
                        [% CASE 'about' %] [% PROCESS about_panel %]
49
                        [% CASE 'perl' %] [% PROCESS perl_panel %]
49
                        [% CASE 'perl' %] [% PROCESS perl_panel %]
50
                        [% CASE 'sysinfo' %] [% PROCESS sysinfo_panel %]
50
                        [% CASE 'sysinfo' %] [% PROCESS sysinfo_panel %]
51
                        [% CASE 'database' %] [% PROCESS database_panel %]
51
                        [% CASE 'team' %] [% PROCESS team_panel %]
52
                        [% CASE 'team' %] [% PROCESS team_panel %]
52
                        [% CASE 'licenses' %] [% PROCESS licenses_panel %]
53
                        [% CASE 'licenses' %] [% PROCESS licenses_panel %]
53
                        [% CASE 'translations' %] [% PROCESS translations_panel %]
54
                        [% CASE 'translations' %] [% PROCESS translations_panel %]
54
                        [% CASE 'history' %] [% PROCESS history_panel %]
55
                        [% CASE 'history' %] [% PROCESS history_panel %]
55
                        [% CASE 'dedications' %] [% PROCESS dedications_panel %]
56
                        [% CASE 'dedications' %] [% PROCESS dedications_panel %]
56
                        [% CASE 'database' %] [% PROCESS database_panel %]
57
                        [% CASE %] [% PROCESS about_panel %]
57
                        [% CASE %] [% PROCESS about_panel %]
58
                    [% END %]
58
                    [% END %]
59
                [% END %]
59
                [% END %]
Lines 781-786 Link Here
781
    [% END # tab=sysinfo %]
781
    [% END # tab=sysinfo %]
782
[% END %]
782
[% END %]
783
783
784
[% BLOCK database_panel %]
785
    [% WRAPPER tab_panel tabname= "database" bt_active = 1 %]
786
        <h2>Database audit</h2>
787
        <div class="alert alert-warning">
788
            <h3>WARNING!!!</h3>
789
            <p>
790
               These commands are only suggestions! They are not a replacement for updatedatabase.pl!<br />
791
               Review the database, updatedatabase.pl, and kohastructure.sql before making any changes!<br />
792
            </p>
793
        </div>
794
        <div>
795
        <p>Run the following SQL to fix the database:</p>
796
        <pre>
797
            <code>[% audit_diff | $raw %]</code>
798
        </pre>
799
        </div>
800
    [% END # tab=database %]
801
[% END %]
802
784
[% BLOCK team_panel %]
803
[% BLOCK team_panel %]
785
    [% WRAPPER tab_panel tabname= "team" bt_active = 1 %]
804
    [% WRAPPER tab_panel tabname= "team" bt_active = 1 %]
786
        <h2>Special thanks to the following organizations</h2>
805
        <h2>Special thanks to the following organizations</h2>
Lines 1343-1356 Link Here
1343
        </p>
1362
        </p>
1344
    [% END # tab=dedications %]
1363
    [% END # tab=dedications %]
1345
[% END %]
1364
[% END %]
1346
1347
[% BLOCK database_panel %]
1348
    [% WRAPPER tab_panel tabname= "database" bt_active = 1 %]
1349
        <h2>Database audit</h2>
1350
        <p>Run the following SQL to fix the database:</p>
1351
        <code>
1352
            [% audit_diff | html %]
1353
        </code>
1354
        <p class="alert alert-warning">[% audit_warning | html %]</p>
1355
    [% END # tab=database %]
1356
[% END %]
(-)a/misc/maintenance/audit_database.pl (-2 / +9 lines)
Lines 11-14 GetOptions( Link Here
11
    "filename=s" => \$filename,
11
    "filename=s" => \$filename,
12
) or die("Error in command line arguments\n");
12
) or die("Error in command line arguments\n");
13
13
14
Koha::Database::Auditor->new( { filename => $filename, is_cli => 1 } )->run;
14
my $auditor = Koha::Database::Auditor->new( { filename => $filename } );
15
my $diff    = $auditor->run;
16
17
my $warning = "\n"
18
    . "WARNING!!!\n"
19
    . "These commands are only suggestions! They are not a replacement for updatedatabase.pl!\n"
20
    . "Review the database, updatedatabase.pl, and kohastructure.sql before making any changes!\n" . "\n";
21
22
print $diff . $warning;
15
- 

Return to bug 36039