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

(-)a/C4/Context.pm (+12 lines)
Lines 220-225 sub KOHAVERSION { Link Here
220
    do $cgidir."/kohaversion.pl" || die "NO $cgidir/kohaversion.pl";
220
    do $cgidir."/kohaversion.pl" || die "NO $cgidir/kohaversion.pl";
221
    return kohaversion();
221
    return kohaversion();
222
}
222
}
223
224
=head2 final_linear_version
225
226
Returns the version number of the final update to run in updatedatabase.pl.
227
This number is equal to the version in kohaversion.pl
228
229
=cut 
230
231
sub final_linear_version {
232
    return KOHAVERSION;
233
}
234
223
=head2 read_config_file
235
=head2 read_config_file
224
236
225
Reads the specified Koha config file. 
237
Reads the specified Koha config file. 
(-)a/installer/data/mysql/updatedatabase.pl (+40 lines)
Lines 6134-6139 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
6134
    SetVersion ($DBversion);
6134
    SetVersion ($DBversion);
6135
}
6135
}
6136
6136
6137
if ( CheckVersion($DBversion) ) {
6138
    print "Upgrade to $DBversion done (Bug 9191: You shouldn't see this)\n";
6139
    SetVersion($DBversion);
6140
}
6141
6142
$DBversion = "3.11.00.XXX";
6143
if ( CheckVersion($DBversion) ) {
6144
    print "Upgrade to $DBversion done (Bug 9191: You should see this)\n";
6145
    SetVersion($DBversion);
6146
}
6147
6137
=head1 FUNCTIONS
6148
=head1 FUNCTIONS
6138
6149
6139
=head2 TableExists($table)
6150
=head2 TableExists($table)
Lines 6215-6218 sub SetVersion { Link Here
6215
    }
6226
    }
6216
    C4::Context::clear_syspref_cache(); # invalidate cached preferences
6227
    C4::Context::clear_syspref_cache(); # invalidate cached preferences
6217
}
6228
}
6229
6230
=head2 CheckVersion
6231
6232
Check whether a given update should be run when passed the proposed version
6233
number. The update will always be run if the proposed version is greater
6234
than the current database version and less than or equal to the version in
6235
kohaversion.pl. The update is also run if the version contains XXX, though
6236
this behavior will be changed following the adoption of non-linear updates
6237
as implemented in bug 7167.
6238
6239
=cut
6240
6241
sub CheckVersion {
6242
    my ($proposed_version) = @_;
6243
    my $version_number = TransformToNum($proposed_version);
6244
6245
    # The following line should be deleted when bug 7167 is pushed
6246
    return 1 if ( $proposed_version =~ m/XXX/ );
6247
6248
    if ( C4::Context->preference("Version") < $version_number
6249
        && $version_number <= TransformToNum( C4::Context->final_linear_version ) )
6250
    {
6251
        return 1;
6252
    }
6253
    else {
6254
        return 0;
6255
    }
6256
}
6257
6218
exit;
6258
exit;
(-)a/t/db_dependent/Context.t (-1 / +17 lines)
Lines 23-28 ok($koha = C4::Context->new, 'C4::Context->new'); Link Here
23
ok($dbh = C4::Context->dbh(), 'Getting dbh from C4::Context');
23
ok($dbh = C4::Context->dbh(), 'Getting dbh from C4::Context');
24
ok($ret = C4::Context->KOHAVERSION, '  (function)  KOHAVERSION = ' . ($ret||''));
24
ok($ret = C4::Context->KOHAVERSION, '  (function)  KOHAVERSION = ' . ($ret||''));
25
ok($ret =       $koha->KOHAVERSION, '       $koha->KOHAVERSION = ' . ($ret||''));
25
ok($ret =       $koha->KOHAVERSION, '       $koha->KOHAVERSION = ' . ($ret||''));
26
ok(
27
    TransformVersionToNum( C4::Context->final_linear_version ) <=
28
      TransformVersionToNum( C4::Context->KOHAVERSION ),
29
    'Final linear version is less than or equal to kohaversion.pl'
30
);
26
my @keys = keys %$koha;
31
my @keys = keys %$koha;
27
diag("Number of keys in \%\$koha: " . scalar @keys); 
32
diag("Number of keys in \%\$koha: " . scalar @keys); 
28
our $width = 0;
33
our $width = 0;
Lines 104-107 is(scalar(@{$history}), 0, 'Did not retrieve syspref from database'); Link Here
104
109
105
done_testing();
110
done_testing();
106
111
112
sub TransformVersionToNum {
113
    my $version = shift;
114
115
    # remove the 3 last . to have a Perl number
116
    $version =~ s/(.*\..*)\.(.*)\.(.*)/$1$2$3/;
117
118
    # three X's at the end indicate that you are testing patch with dbrev
119
    # change it into 999
120
    # prevents error on a < comparison between strings (should be: lt)
121
    $version =~ s/XXX$/999/;
122
    return $version;
123
}
107
1;
124
1;
108
- 

Return to bug 9191