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

(-)a/C4/Installer.pm (-6 / +2 lines)
Lines 29-34 use DBI; Link Here
29
use C4::Context;
29
use C4::Context;
30
use Koha::Schema;
30
use Koha::Schema;
31
use Koha;
31
use Koha;
32
use Koha::Installer;
32
33
33
use vars qw(@ISA @EXPORT);
34
use vars qw(@ISA @EXPORT);
34
BEGIN {
35
BEGIN {
Lines 929-940 to a number, with just 1 . Link Here
929
930
930
sub TransformToNum {
931
sub TransformToNum {
931
    my $version = shift;
932
    my $version = shift;
932
    # remove the 3 last . to have a Perl number
933
    $version = Koha::Installer::TransformToNum($version);
933
    $version =~ s/(.*\..*)\.(.*)\.(.*)/$1$2$3/;
934
    # three X's at the end indicate that you are testing patch with dbrev
935
    # change it into 999
936
    # prevents error on a < comparison between strings (should be: lt)
937
    $version =~ s/XXX$/999/;
938
    return $version;
934
    return $version;
939
}
935
}
940
936
(-)a/Koha/Installer.pm (+44 lines)
Line 0 Link Here
1
package Koha::Installer;
2
3
use Modern::Perl;
4
5
require Koha;
6
require Koha::Database;
7
8
sub needs_update {
9
    my $dbh = Koha::Database::dbh();
10
    my $sql = "SELECT value FROM systempreferences WHERE variable = 'Version'";
11
    my $sth = $dbh->prepare($sql);
12
    $sth->execute();
13
    my $row          = $sth->fetchrow_arrayref();
14
    my $db_version   = $row->[0];
15
    my $koha_version = Koha->version;
16
    my $code_version = TransformToNum($koha_version);
17
18
    if ( $db_version == $code_version ) {
19
        return;
20
    }
21
    return 1;
22
}
23
24
=head2 TransformToNum
25
26
Transform the Koha version from a 4 parts string
27
to a number, with just 1 .
28
29
=cut
30
31
sub TransformToNum {
32
    my $version = shift;
33
34
    # remove the 3 last . to have a Perl number
35
    $version =~ s/(.*\..*)\.(.*)\.(.*)/$1$2$3/;
36
37
    # three X's at the end indicate that you are testing patch with dbrev
38
    # change it into 999
39
    # prevents error on a < comparison between strings (should be: lt)
40
    $version =~ s/XXX$/999/;
41
    return $version;
42
}
43
44
1;
(-)a/installer/data/mysql/updatedatabase.pl (-1 / +7 lines)
Lines 27-32 Link Here
27
27
28
# NOTE: Please keep the version in kohaversion.pl up-to-date!
28
# NOTE: Please keep the version in kohaversion.pl up-to-date!
29
29
30
BEGIN {
31
    use Koha::Installer;
32
    if ( !Koha::Installer->needs_update ) {
33
        exit;
34
    }
35
}
36
30
use Modern::Perl;
37
use Modern::Perl;
31
38
32
use feature 'say';
39
use feature 'say';
33
- 

Return to bug 34088