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; |