diff --git a/Koha/Installer.pm b/Koha/Installer.pm new file mode 100644 index 0000000000..4d2f3d12ac --- /dev/null +++ b/Koha/Installer.pm @@ -0,0 +1,60 @@ +package Koha::Installer; + +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; + +use C4::Context; + +=head1 NAME + +Koha::Installer - Class that provides installation related methods + +=head1 API + +=head2 Class Methods + +=cut + +=head3 check_db_row_format + +=cut + +sub check_db_row_format { + my ($class) = @_; + my %result = (); + my $database = C4::Context->config('database'); + if ($database){ + my $dbh = C4::Context->dbh; + my $sql = q# + SELECT count(table_name) + FROM information_schema.tables + WHERE + table_schema = ? + AND row_format != "Dynamic" + #; + my $sth = $dbh->prepare($sql); + $sth->execute($database); + my $row = $sth->fetchrow_arrayref; + my $count = $row->[0]; + if ($count){ + $result{count} = $count; + } + } + return \%result; +} + +1; diff --git a/about.pl b/about.pl index 1296996041..0423d6a6b5 100755 --- a/about.pl +++ b/about.pl @@ -54,6 +54,7 @@ use Koha::Illrequest::Config; use Koha::SearchEngine::Elasticsearch; use Koha::Logger; use Koha::Filter::MARC::ViewPolicy; +use Koha::Installer; use C4::Members::Statistics; @@ -624,6 +625,14 @@ $template->param( 'bad_yaml_prefs' => \@bad_yaml_prefs ) if @bad_yaml_prefs; } } +#BZ 28267: Warn administrators if there are database rows with a format other than 'DYNAMIC' +{ + my $db_row_format_result = Koha::Installer->check_db_row_format(); + if ( my $count = $db_row_format_result->{count} ){ + $template->param( warnDbRowFormat => $count ); + } +} + my %versions = C4::Context::get_versions(); $template->param( diff --git a/installer/install.pl b/installer/install.pl index f8de23e332..d7be88cdbb 100755 --- a/installer/install.pl +++ b/installer/install.pl @@ -32,6 +32,7 @@ use C4::Installer; use C4::Installer::PerlModules; use Koha; +use Koha::Installer; my $query = CGI->new; my $step = $query->param('step'); @@ -185,6 +186,13 @@ elsif ( $step && $step == 2 ) { } } $template->param( "checkgrantaccess" => $grantaccess ); + + my $db_row_format_result = Koha::Installer->check_db_row_format(); + if ( my $count = $db_row_format_result->{count} ){ + $template->param( warnDbRowFormat => $count ); + $template->param( error => "InnoDB row format" ); + } + } # End mysql connect check... elsif ( $info{dbms} eq "Pg" ) { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt index 2422fc9cc7..5039212cf6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt @@ -267,7 +267,16 @@ [% SET warnMissingCompiledFiles = 1 %] [% END %] [% WRAPPER tab_panel tabname= "sysinfo" %] - [% IF warnPrefRequireChoosingExistingAuthority || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatronOPACPrivacy || warnPrefAnonymousPatronAnonSuggestions || warnPrefAnonymousPatronOPACPrivacy_PatronDoesNotExist || warnPrefAnonymousPatronAnonSuggestions_PatronDoesNotExist || warnPrefKohaAdminEmailAddress || warnPrefOpacHiddenItems || invalid_yesno.count || warnNoActiveCurrency || warnIsRootUser || xml_config_warnings.size || AutoSelfCheckPatronDoesNotHaveSelfCheckPerm || AutoSelfCheckPatronHasTooManyPerm || warnStatisticsFieldsError || warnNoTemplateCaching || warnILLConfiguration || has_ai_issues || oauth2_missing_deps || bad_yaml_prefs || warnRelationships || log4perl_errors || config_bcrypt_settings_no_set || warnHiddenBiblionumbers.size || warnConnectBroker || elasticsearch_has_missing || warnMissingCompiledFiles%] + [% IF warnPrefRequireChoosingExistingAuthority || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatronOPACPrivacy || warnPrefAnonymousPatronAnonSuggestions || warnPrefAnonymousPatronOPACPrivacy_PatronDoesNotExist || warnPrefAnonymousPatronAnonSuggestions_PatronDoesNotExist || warnPrefKohaAdminEmailAddress || warnPrefOpacHiddenItems || invalid_yesno.count || warnNoActiveCurrency || warnIsRootUser || xml_config_warnings.size || AutoSelfCheckPatronDoesNotHaveSelfCheckPerm || AutoSelfCheckPatronHasTooManyPerm || warnStatisticsFieldsError || warnNoTemplateCaching || warnILLConfiguration || has_ai_issues || oauth2_missing_deps || bad_yaml_prefs || warnRelationships || log4perl_errors || config_bcrypt_settings_no_set || warnHiddenBiblionumbers.size || warnConnectBroker || elasticsearch_has_missing || warnMissingCompiledFiles || warnDbRowFormat %] + [% IF ( warnDbRowFormat ) %] +

Database row format incorrect

+

Database tables with a row format other than 'DYNAMIC': [% warnDbRowFormat | html %]

+

You may experience problems upgrading to newer versions of Koha unless you update the row format for your database tables.

+

To know how to avoid this problem see the related wiki page: + Database row format +

+ [% END %] + [% IF (warnIsRootUser) %]

Warning regarding current user

You are logged in as the database administrative user. This is not recommended because some parts of Koha will not function as expected when using this account.

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/installer/step2.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/installer/step2.tt index fab5eb4355..d44cc4c2ad 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/installer/step2.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/installer/step2.tt @@ -49,6 +49,15 @@

Need help? For help with granting permissions, please search online for "[% dbms | $HtmlTags tag=>'code' %] manual grant permissions"

[% END %] + [% IF ( warnDbRowFormat ) %] + + [% END %] [% ELSE %]

Please create the database before continuing.

diff --git a/t/db_dependent/Koha/Installer.t b/t/db_dependent/Koha/Installer.t new file mode 100755 index 0000000000..f6b6878e61 --- /dev/null +++ b/t/db_dependent/Koha/Installer.t @@ -0,0 +1,48 @@ +#!/usr/bin/perl + +# This file is part of Koha +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; + +use Test::More tests => 1; + +use C4::Context; +use Koha::Database; +use Koha::Installer; + +use t::lib::TestBuilder; + +my $schema = Koha::Database->new->schema; + +subtest 'check_db_row_format() tests' => sub { + + plan tests => 2; + + $schema->storage->txn_begin; + + my $dbh = C4::Context->dbh; + $dbh->do("ALTER TABLE tags row_format=COMPACT;"); + + my $pos_result = Koha::Installer->check_db_row_format; + is($pos_result->{count},1,"Detected problem table"); + + $dbh->do("ALTER TABLE tags row_format=DYNAMIC;"); + + my $neg_result = Koha::Installer->check_db_row_format; + is($neg_result->{count},undef,"Detected no problem tables"); + + $schema->storage->txn_rollback; +};