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

(-)a/C4/Installer.pm (-1 / +25 lines)
Lines 34-40 use vars qw(@ISA @EXPORT); Link Here
34
BEGIN {
34
BEGIN {
35
    require Exporter;
35
    require Exporter;
36
    @ISA = qw( Exporter );
36
    @ISA = qw( Exporter );
37
    push @EXPORT, qw( primary_key_exists unique_key_exists foreign_key_exists index_exists column_exists TableExists marc_framework_sql_list TransformToNum CheckVersion NewVersion SetVersion sanitize_zero_date update get_db_entries get_atomic_updates run_atomic_updates );
37
    push @EXPORT, qw( primary_key_exists unique_key_exists foreign_key_exists index_exists column_exists TableExists marc_framework_sql_list TransformToNum CheckVersion NewVersion SetVersion sanitize_zero_date update get_db_entries get_atomic_updates run_atomic_updates has_non_dynamic_row_format );
38
};
38
};
39
39
40
=head1 NAME
40
=head1 NAME
Lines 1039-1044 sub sanitize_zero_date { Link Here
1039
    }
1039
    }
1040
}
1040
}
1041
1041
1042
=head3 has_non_dynamic_row_format
1043
1044
Return the number of tables with row_format that is not Dynamic
1045
1046
=cut
1047
1048
sub has_non_dynamic_row_format {
1049
    my ($class) = @_;
1050
    my $database = C4::Context->config('database');
1051
    my $count = 0;
1052
    if ($database){
1053
        my $dbh = C4::Context->dbh;
1054
        my $sql = q#
1055
            SELECT count(table_name)
1056
            FROM information_schema.tables
1057
            WHERE
1058
                table_schema = ?
1059
                AND row_format != "Dynamic"
1060
        #;
1061
        ( $count ) = $dbh->selectrow_array($sql, undef, $database);
1062
    }
1063
    return $count;
1064
}
1065
1042
=head1 AUTHOR
1066
=head1 AUTHOR
1043
1067
1044
C4::Installer is a refactoring of logic originally from installer/installer.pl, which was
1068
C4::Installer is a refactoring of logic originally from installer/installer.pl, which was
(-)a/Koha.pm (-1 / +1 lines)
Lines 29-35 use vars qw{ $VERSION }; Link Here
29
# - #4 : the developer version. The 4th number is the database subversion.
29
# - #4 : the developer version. The 4th number is the database subversion.
30
#        used by developers when the database changes. updatedatabase take care of the changes itself
30
#        used by developers when the database changes. updatedatabase take care of the changes itself
31
#        and is automatically called by Auth.pm when needed.
31
#        and is automatically called by Auth.pm when needed.
32
$VERSION = "22.12.00.024";
32
$VERSION = "22.12.00.025";
33
33
34
sub version {
34
sub version {
35
    return $VERSION;
35
    return $VERSION;
(-)a/Koha/Installer.pm (-60 lines)
Lines 1-60 Link Here
1
package Koha::Installer;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use C4::Context;
21
22
=head1 NAME
23
24
Koha::Installer - Class that provides installation related methods
25
26
=head1 API
27
28
=head2 Class Methods
29
30
=cut
31
32
=head3 check_db_row_format
33
34
=cut
35
36
sub check_db_row_format {
37
    my ($class) = @_;
38
    my %result = ();
39
    my $database = C4::Context->config('database');
40
    if ($database){
41
        my $dbh = C4::Context->dbh;
42
        my $sql = q#
43
            SELECT count(table_name)
44
            FROM information_schema.tables
45
            WHERE
46
                table_schema = ?
47
                AND row_format != "Dynamic"
48
        #;
49
        my $sth = $dbh->prepare($sql);
50
        $sth->execute($database);
51
        my $row = $sth->fetchrow_arrayref;
52
        my $count = $row->[0];
53
        if ($count){
54
            $result{count} = $count;
55
        }
56
    }
57
    return \%result;
58
}
59
60
1;
(-)a/about.pl (-5 / +2 lines)
Lines 37-42 use Encode; Link Here
37
use C4::Output qw( output_html_with_http_headers );
37
use C4::Output qw( output_html_with_http_headers );
38
use C4::Auth qw( get_template_and_user get_user_subpermissions );
38
use C4::Auth qw( get_template_and_user get_user_subpermissions );
39
use C4::Context;
39
use C4::Context;
40
use C4::Installer;
40
use C4::Installer::PerlModules;
41
use C4::Installer::PerlModules;
41
42
42
use Koha;
43
use Koha;
Lines 55-61 use Koha::Illrequest::Config; Link Here
55
use Koha::SearchEngine::Elasticsearch;
56
use Koha::SearchEngine::Elasticsearch;
56
use Koha::Logger;
57
use Koha::Logger;
57
use Koha::Filter::MARC::ViewPolicy;
58
use Koha::Filter::MARC::ViewPolicy;
58
use Koha::Installer;
59
59
60
use C4::Members::Statistics;
60
use C4::Members::Statistics;
61
61
Lines 632-641 $template->param( 'bad_yaml_prefs' => \@bad_yaml_prefs ) if @bad_yaml_prefs; Link Here
632
632
633
#BZ 28267: Warn administrators if there are database rows with a format other than 'DYNAMIC'
633
#BZ 28267: Warn administrators if there are database rows with a format other than 'DYNAMIC'
634
{
634
{
635
    my $db_row_format_result = Koha::Installer->check_db_row_format();
635
    $template->param( warnDbRowFormat => C4::Installer->has_non_dynamic_row_format );
636
    if ( my $count = $db_row_format_result->{count} ){
637
        $template->param( warnDbRowFormat => $count );
638
    }
639
}
636
}
640
637
641
my %versions = C4::Context::get_versions();
638
my %versions = C4::Context::get_versions();
(-)a/installer/install.pl (-3 / +1 lines)
Lines 32-38 use C4::Installer; Link Here
32
use C4::Installer::PerlModules;
32
use C4::Installer::PerlModules;
33
33
34
use Koha;
34
use Koha;
35
use Koha::Installer;
36
35
37
my $query = CGI->new;
36
my $query = CGI->new;
38
my $step  = $query->param('step');
37
my $step  = $query->param('step');
Lines 187-194 elsif ( $step && $step == 2 ) { Link Here
187
                }
186
                }
188
                $template->param( "checkgrantaccess" => $grantaccess );
187
                $template->param( "checkgrantaccess" => $grantaccess );
189
188
190
                my $db_row_format_result = Koha::Installer->check_db_row_format();
189
                if ( my $count = $installer->has_non_dynamic_row_format ) {
191
                if ( my $count = $db_row_format_result->{count} ){
192
                    $template->param( warnDbRowFormat => $count );
190
                    $template->param( warnDbRowFormat => $count );
193
                    $template->param( error => "InnoDB row format" );
191
                    $template->param( error => "InnoDB row format" );
194
                }
192
                }
(-)a/t/db_dependent/Koha/Installer.t (-49 lines)
Lines 1-48 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use Test::More tests => 1;
21
22
use C4::Context;
23
use Koha::Database;
24
use Koha::Installer;
25
26
use t::lib::TestBuilder;
27
28
my $schema  = Koha::Database->new->schema;
29
30
subtest 'check_db_row_format() tests' => sub {
31
32
    plan tests => 2;
33
34
    $schema->storage->txn_begin;
35
36
    my $dbh = C4::Context->dbh;
37
    $dbh->do("ALTER TABLE tags row_format=COMPACT;");
38
39
    my $pos_result = Koha::Installer->check_db_row_format;
40
    is($pos_result->{count},1,"Detected problem table");
41
42
    $dbh->do("ALTER TABLE tags row_format=DYNAMIC;");
43
44
    my $neg_result = Koha::Installer->check_db_row_format;
45
    is($neg_result->{count},undef,"Detected no problem tables");
46
47
    $schema->storage->txn_rollback;
48
};
49
- 

Return to bug 28267