Line 0
Link Here
|
|
|
1 |
package Koha::Installer; |
2 |
|
3 |
use Modern::Perl; |
4 |
|
5 |
require Koha; |
6 |
require Koha::Database; |
7 |
|
8 |
sub import { |
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 |
if ($db_version == $code_version){ |
18 |
exit; |
19 |
} |
20 |
} |
21 |
|
22 |
=head2 TransformToNum |
23 |
|
24 |
Transform the Koha version from a 4 parts string |
25 |
to a number, with just 1 . |
26 |
|
27 |
=cut |
28 |
|
29 |
sub TransformToNum { |
30 |
my $version = shift; |
31 |
# remove the 3 last . to have a Perl number |
32 |
$version =~ s/(.*\..*)\.(.*)\.(.*)/$1$2$3/; |
33 |
# three X's at the end indicate that you are testing patch with dbrev |
34 |
# change it into 999 |
35 |
# prevents error on a < comparison between strings (should be: lt) |
36 |
$version =~ s/XXX$/999/; |
37 |
return $version; |
38 |
} |
39 |
|
40 |
1; |