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 928-935 sub message_broker_check { Link Here
928
928
929
if ( $tab eq 'database' ) {
929
if ( $tab eq 'database' ) {
930
    use Koha::Database::Auditor;
930
    use Koha::Database::Auditor;
931
    my $db_auditor = Koha::Database::Auditor->new( { is_cli => 0 } );
931
    my $db_auditor = Koha::Database::Auditor->new();
932
    my $audit_diff = $db_auditor->run;
932
    my $audit_diff = $db_auditor->run;
933
    $template->param( audit_diff => $audit_diff, audit_warning => $db_auditor->get_warning );
933
    $template->param( audit_diff => $audit_diff );
934
}
934
}
935
output_html_with_http_headers $query, $cookie, $template->output;
935
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 795-800 Link Here
795
    [% END # tab=sysinfo %]
795
    [% END # tab=sysinfo %]
796
[% END %]
796
[% END %]
797
797
798
[% BLOCK database_panel %]
799
    [% WRAPPER tab_panel tabname= "database" bt_active = 1 %]
800
        <h2>Database audit</h2>
801
        <div class="alert alert-warning">
802
            <h3>WARNING!!!</h3>
803
            <p>
804
               These commands are only suggestions! They are not a replacement for updatedatabase.pl!<br />
805
               Review the database, updatedatabase.pl, and kohastructure.sql before making any changes!<br />
806
            </p>
807
        </div>
808
        <div>
809
        <p>Run the following SQL to fix the database:</p>
810
        <pre>
811
            <code>[% audit_diff | $raw %]</code>
812
        </pre>
813
        </div>
814
    [% END # tab=database %]
815
[% END %]
816
798
[% BLOCK team_panel %]
817
[% BLOCK team_panel %]
799
    [% WRAPPER tab_panel tabname= "team" bt_active = 1 %]
818
    [% WRAPPER tab_panel tabname= "team" bt_active = 1 %]
800
        <h2>Special thanks to the following organizations</h2>
819
        <h2>Special thanks to the following organizations</h2>
Lines 1357-1370 Link Here
1357
        </p>
1376
        </p>
1358
    [% END # tab=dedications %]
1377
    [% END # tab=dedications %]
1359
[% END %]
1378
[% END %]
1360
1361
[% BLOCK database_panel %]
1362
    [% WRAPPER tab_panel tabname= "database" bt_active = 1 %]
1363
        <h2>Database audit</h2>
1364
        <p>Run the following SQL to fix the database:</p>
1365
        <code>
1366
            [% audit_diff | html %]
1367
        </code>
1368
        <p class="alert alert-warning">[% audit_warning | html %]</p>
1369
    [% END # tab=database %]
1370
[% 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