Bug 28267: Simplify things
We don't need: * a separate Koha::Installer module when we already have C4::Installer * the tests as they are actually modifying the DB structure without rolling back * An unecessary complicated subroutine, just make is simple WNC amended patch: Remove change to Koha.pm Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
b76fb9cf46
commit
f394bf61cf
|
|
@ -34,7 +34,7 @@ use vars qw(@ISA @EXPORT);
|
|||
BEGIN {
|
||||
require Exporter;
|
||||
@ISA = qw( Exporter );
|
||||
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 );
|
||||
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 );
|
||||
};
|
||||
|
||||
=head1 NAME
|
||||
|
|
@ -1039,6 +1039,30 @@ sub sanitize_zero_date {
|
|||
}
|
||||
}
|
||||
|
||||
=head3 has_non_dynamic_row_format
|
||||
|
||||
Return the number of tables with row_format that is not Dynamic
|
||||
|
||||
=cut
|
||||
|
||||
sub has_non_dynamic_row_format {
|
||||
my ($class) = @_;
|
||||
my $database = C4::Context->config('database');
|
||||
my $count = 0;
|
||||
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"
|
||||
#;
|
||||
( $count ) = $dbh->selectrow_array($sql, undef, $database);
|
||||
}
|
||||
return $count;
|
||||
}
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
C4::Installer is a refactoring of logic originally from installer/installer.pl, which was
|
||||
|
|
|
|||
|
|
@ -1,60 +0,0 @@
|
|||
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 <http://www.gnu.org/licenses>.
|
||||
|
||||
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;
|
||||
7
about.pl
7
about.pl
|
|
@ -37,6 +37,7 @@ use Encode;
|
|||
use C4::Output qw( output_html_with_http_headers );
|
||||
use C4::Auth qw( get_template_and_user get_user_subpermissions );
|
||||
use C4::Context;
|
||||
use C4::Installer;
|
||||
use C4::Installer::PerlModules;
|
||||
|
||||
use Koha;
|
||||
|
|
@ -55,7 +56,6 @@ use Koha::Illrequest::Config;
|
|||
use Koha::SearchEngine::Elasticsearch;
|
||||
use Koha::Logger;
|
||||
use Koha::Filter::MARC::ViewPolicy;
|
||||
use Koha::Installer;
|
||||
|
||||
use C4::Members::Statistics;
|
||||
|
||||
|
|
@ -632,10 +632,7 @@ $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 );
|
||||
}
|
||||
$template->param( warnDbRowFormat => C4::Installer->has_non_dynamic_row_format );
|
||||
}
|
||||
|
||||
my %versions = C4::Context::get_versions();
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ use C4::Installer;
|
|||
use C4::Installer::PerlModules;
|
||||
|
||||
use Koha;
|
||||
use Koha::Installer;
|
||||
|
||||
my $query = CGI->new;
|
||||
my $step = $query->param('step');
|
||||
|
|
@ -187,8 +186,7 @@ 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} ){
|
||||
if ( my $count = $installer->has_non_dynamic_row_format ) {
|
||||
$template->param( warnDbRowFormat => $count );
|
||||
$template->param( error => "InnoDB row format" );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,48 +0,0 @@
|
|||
#!/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 <http://www.gnu.org/licenses>.
|
||||
|
||||
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;
|
||||
};
|
||||
Loading…
Reference in New Issue