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 (+41 lines)
Lines 6114-6119 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
6114
    SetVersion($DBversion);
6114
    SetVersion($DBversion);
6115
}
6115
}
6116
6116
6117
$DBversion = "3.11.00.005";
6118
if ( CheckVersion($DBversion) ) {
6119
    print "Upgrade to $DBversion done (Bug 9191: You shouldn't see this)\n";
6120
    SetVersion($DBversion);
6121
}
6122
6123
$DBversion = "3.11.00.XXX";
6124
if ( CheckVersion($DBversion) ) {
6125
    print "Upgrade to $DBversion done (Bug 9191: You should see this)\n";
6126
    SetVersion($DBversion);
6127
}
6128
6117
=head1 FUNCTIONS
6129
=head1 FUNCTIONS
6118
6130
6119
=head2 TableExists($table)
6131
=head2 TableExists($table)
Lines 6195-6198 sub SetVersion { Link Here
6195
    }
6207
    }
6196
    C4::Context::clear_syspref_cache(); # invalidate cached preferences
6208
    C4::Context::clear_syspref_cache(); # invalidate cached preferences
6197
}
6209
}
6210
6211
=head2 CheckVersion
6212
6213
Check whether a given update should be run when passed the proposed version
6214
number. The update will always be run if the proposed version is greater
6215
than the current database version and less than or equal to the version in
6216
kohaversion.pl. The update is also run if the version contains XXX, though
6217
this behavior will be changed following the adoption of non-linear updates
6218
as implemented in bug 7167.
6219
6220
=cut
6221
6222
sub CheckVersion {
6223
    my ($proposed_version) = @_;
6224
    my $version_number = TransformToNum($proposed_version);
6225
6226
    # The following line should be deleted when bug 7167 is pushed
6227
    return 1 if ( $proposed_version =~ m/XXX/ );
6228
6229
    if ( C4::Context->preference("Version") < $version_number
6230
        && $version_number <= TransformToNum( C4::Context->final_linear_version ) )
6231
    {
6232
        return 1;
6233
    }
6234
    else {
6235
        return 0;
6236
    }
6237
}
6238
6198
exit;
6239
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