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

(-)a/C4/Auth.pm (-3 / +4 lines)
Lines 30-35 use C4::Templates; # to get the template Link Here
30
use C4::Languages;
30
use C4::Languages;
31
use C4::Branch;       # GetBranches
31
use C4::Branch;       # GetBranches
32
use C4::Search::History;
32
use C4::Search::History;
33
use Koha;
33
use Koha::AuthUtils qw(hash_password);
34
use Koha::AuthUtils qw(hash_password);
34
use POSIX qw/strftime/;
35
use POSIX qw/strftime/;
35
use List::MoreUtils qw/ any /;
36
use List::MoreUtils qw/ any /;
Lines 660-666 sub _version_check { Link Here
660
    # there is no DB version, it's a fresh install,
661
    # there is no DB version, it's a fresh install,
661
    # go to web installer
662
    # go to web installer
662
    # there is a DB version, compare it to the code version
663
    # there is a DB version, compare it to the code version
663
    my $kohaversion = C4::Context::KOHAVERSION;
664
    my $kohaversion = Koha::version();
664
665
665
    # remove the 3 last . to have a Perl number
666
    # remove the 3 last . to have a Perl number
666
    $kohaversion =~ s/(.*\..*)\.(.*)\.(.*)/$1$2$3/;
667
    $kohaversion =~ s/(.*\..*)\.(.*)\.(.*)/$1$2$3/;
Lines 1309-1315 sub check_api_auth { Link Here
1309
        # database has not been installed yet
1310
        # database has not been installed yet
1310
        return ( "maintenance", undef, undef );
1311
        return ( "maintenance", undef, undef );
1311
    }
1312
    }
1312
    my $kohaversion = C4::Context::KOHAVERSION;
1313
    my $kohaversion = Koha::version();
1313
    $kohaversion =~ s/(.*\..*)\.(.*)\.(.*)/$1$2$3/;
1314
    $kohaversion =~ s/(.*\..*)\.(.*)\.(.*)/$1$2$3/;
1314
    if ( C4::Context->preference('Version') < $kohaversion ) {
1315
    if ( C4::Context->preference('Version') < $kohaversion ) {
1315
1316
Lines 1563-1569 sub check_cookie_auth { Link Here
1563
        # database has not been installed yet
1564
        # database has not been installed yet
1564
        return ( "maintenance", undef );
1565
        return ( "maintenance", undef );
1565
    }
1566
    }
1566
    my $kohaversion = C4::Context::KOHAVERSION;
1567
    my $kohaversion = Koha::version();
1567
    $kohaversion =~ s/(.*\..*)\.(.*)\.(.*)/$1$2$3/;
1568
    $kohaversion =~ s/(.*\..*)\.(.*)\.(.*)/$1$2$3/;
1568
    if ( C4::Context->preference('Version') < $kohaversion ) {
1569
    if ( C4::Context->preference('Version') < $kohaversion ) {
1569
1570
(-)a/C4/Context.pm (-31 / +2 lines)
Lines 103-108 use ZOOM; Link Here
103
use XML::Simple;
103
use XML::Simple;
104
use C4::Boolean;
104
use C4::Boolean;
105
use C4::Debug;
105
use C4::Debug;
106
use Koha;
106
use POSIX ();
107
use POSIX ();
107
use DateTime::TimeZone;
108
use DateTime::TimeZone;
108
use Module::Load::Conditional qw(can_load);
109
use Module::Load::Conditional qw(can_load);
Lines 204-239 $context = undef; # Initially, no context is set Link Here
204
@context_stack = ();        # Initially, no saved contexts
205
@context_stack = ();        # Initially, no saved contexts
205
206
206
207
207
=head2 KOHAVERSION
208
209
returns the kohaversion stored in kohaversion.pl file
210
211
=cut
212
213
sub KOHAVERSION {
214
    my $cgidir = C4::Context->intranetdir;
215
216
    # Apparently the GIT code does not run out of a CGI-BIN subdirectory
217
    # but distribution code does?  (Stan, 1jan08)
218
    if(-d $cgidir . "/cgi-bin"){
219
        my $cgidir .= "/cgi-bin";
220
    }
221
    
222
    do $cgidir."/kohaversion.pl" || die "NO $cgidir/kohaversion.pl";
223
    return kohaversion();
224
}
225
226
=head2 final_linear_version
227
228
Returns the version number of the final update to run in updatedatabase.pl.
229
This number is equal to the version in kohaversion.pl
230
231
=cut
232
233
sub final_linear_version {
234
    return KOHAVERSION;
235
}
236
237
=head2 read_config_file
208
=head2 read_config_file
238
209
239
Reads the specified Koha config file. 
210
Reads the specified Koha config file. 
Lines 1199-1205 Gets various version info, for core Koha packages, Currently called from carp ha Link Here
1199
# A little example sub to show more debugging info for CGI::Carp
1170
# A little example sub to show more debugging info for CGI::Carp
1200
sub get_versions {
1171
sub get_versions {
1201
    my %versions;
1172
    my %versions;
1202
    $versions{kohaVersion}  = KOHAVERSION();
1173
    $versions{kohaVersion}  = Koha::version();
1203
    $versions{kohaDbVersion} = C4::Context->preference('version');
1174
    $versions{kohaDbVersion} = C4::Context->preference('version');
1204
    $versions{osVersion} = join(" ", POSIX::uname());
1175
    $versions{osVersion} = join(" ", POSIX::uname());
1205
    $versions{perlVersion} = $];
1176
    $versions{perlVersion} = $];
(-)a/C4/External/OverDrive.pm (-1 / +2 lines)
Lines 20-25 package C4::External::OverDrive; Link Here
20
use strict;
20
use strict;
21
use warnings;
21
use warnings;
22
22
23
use Koha;
23
use JSON;
24
use JSON;
24
use Koha::Cache;
25
use Koha::Cache;
25
use HTTP::Request;
26
use HTTP::Request;
Lines 39-45 BEGIN { Link Here
39
40
40
sub _request {
41
sub _request {
41
    my ( $request ) = @_;
42
    my ( $request ) = @_;
42
    my $ua = LWP::UserAgent->new( "Koha " . C4::Context->KOHAVERSION );
43
    my $ua = LWP::UserAgent->new( "Koha " . $KOHA::VERSION );
43
44
44
    my $response;
45
    my $response;
45
    eval {
46
    eval {
(-)a/C4/Installer.pm (-1 / +2 lines)
Lines 24-29 use Encode qw( encode is_utf8 ); Link Here
24
our $VERSION = 3.07.00.049;
24
our $VERSION = 3.07.00.049;
25
use C4::Context;
25
use C4::Context;
26
use C4::Installer::PerlModules;
26
use C4::Installer::PerlModules;
27
use Koha;
27
28
28
=head1 NAME
29
=head1 NAME
29
30
Lines 389-395 Koha software version. Link Here
389
sub set_version_syspref {
390
sub set_version_syspref {
390
    my $self = shift;
391
    my $self = shift;
391
392
392
    my $kohaversion=C4::Context::KOHAVERSION;
393
    my $kohaversion = Koha::version();
393
    # remove the 3 last . to have a Perl number
394
    # remove the 3 last . to have a Perl number
394
    $kohaversion =~ s/(.*\..*)\.(.*)\.(.*)/$1$2$3/;
395
    $kohaversion =~ s/(.*\..*)\.(.*)\.(.*)/$1$2$3/;
395
    if (C4::Context->preference('Version')) {
396
    if (C4::Context->preference('Version')) {
(-)a/Koha.pm (+20 lines)
Line 0 Link Here
1
package Koha;
2
3
use Modern::Perl;
4
5
use vars qw{ $VERSION };
6
7
#the kohaversion is divided in 4 parts :
8
# - #1 : the major number. 3 atm
9
# - #2 : the functional release. 00 atm
10
# - #3 : the subnumber, moves only on a public release
11
# - #4 : the developer version. The 4th number is the database subversion.
12
#        used by developers when the database changes. updatedatabase take care of the changes itself
13
#        and is automatically called by Auth.pm when needed.
14
$VERSION = "3.19.00.031";
15
16
sub version {
17
    return $VERSION;
18
}
19
20
1;
(-)a/Koha/Template/Plugin/Koha.pm (-1 / +2 lines)
Lines 23-28 use Encode qw( encode ); Link Here
23
use base qw( Template::Plugin );
23
use base qw( Template::Plugin );
24
24
25
use C4::Context;
25
use C4::Context;
26
use Koha;
26
27
27
=pod
28
=pod
28
29
Lines 46-52 sub Preference { Link Here
46
}
47
}
47
48
48
sub Version {
49
sub Version {
49
    my $version_string = C4::Context::KOHAVERSION;
50
    my $version_string = Koha::version();
50
    my ($major,$minor,$maintenance,$development) = split('\.',$version_string);
51
    my ($major,$minor,$maintenance,$development) = split('\.',$version_string);
51
52
52
    return {
53
    return {
(-)a/about.pl (-1 / +3 lines)
Lines 33-38 use C4::Auth; Link Here
33
use C4::Context;
33
use C4::Context;
34
use C4::Installer;
34
use C4::Installer;
35
35
36
use Koha;
37
36
#use Smart::Comments '####';
38
#use Smart::Comments '####';
37
39
38
my $query = new CGI;
40
my $query = new CGI;
Lines 47-53 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
47
    }
49
    }
48
);
50
);
49
51
50
my $kohaVersion   = C4::Context::KOHAVERSION;
52
my $kohaVersion   = Koha::version();
51
my $osVersion     = `uname -a`;
53
my $osVersion     = `uname -a`;
52
my $perl_path = $^X;
54
my $perl_path = $^X;
53
if ($^O ne 'VMS') {
55
if ($^O ne 'VMS') {
(-)a/installer/data/mysql/updatedatabase.pl (-1 / +3 lines)
Lines 39-44 use C4::Installer; Link Here
39
use C4::Dates;
39
use C4::Dates;
40
use Koha::Database;
40
use Koha::Database;
41
41
42
use Koha;
43
42
use MARC::Record;
44
use MARC::Record;
43
use MARC::File::XML ( BinaryEncoding => 'utf8' );
45
use MARC::File::XML ( BinaryEncoding => 'utf8' );
44
46
Lines 10382-10388 sub CheckVersion { Link Here
10382
    return 1 if ( $proposed_version =~ m/XXX/ );
10384
    return 1 if ( $proposed_version =~ m/XXX/ );
10383
10385
10384
    if ( C4::Context->preference("Version") < $version_number
10386
    if ( C4::Context->preference("Version") < $version_number
10385
        && $version_number <= TransformToNum( C4::Context->final_linear_version ) )
10387
        && $version_number <= TransformToNum( $Koha::VERSION ) )
10386
    {
10388
    {
10387
        return 1;
10389
        return 1;
10388
    }
10390
    }
(-)a/installer/install.pl (-1 / +3 lines)
Lines 14-19 use C4::Templates; Link Here
14
use C4::Languages qw(getAllLanguages getTranslatedLanguages);
14
use C4::Languages qw(getAllLanguages getTranslatedLanguages);
15
use C4::Installer;
15
use C4::Installer;
16
16
17
use Koha;
18
17
my $query = new CGI;
19
my $query = new CGI;
18
my $step  = $query->param('step');
20
my $step  = $query->param('step');
19
21
Lines 398-404 elsif ( $step && $step == 3 ) { Link Here
398
                $dbversion = "$1.$2.$3.$4";
400
                $dbversion = "$1.$2.$3.$4";
399
                $template->param("upgrading" => 1,
401
                $template->param("upgrading" => 1,
400
                                "dbversion" => $dbversion,
402
                                "dbversion" => $dbversion,
401
                                "kohaversion" => C4::Context->KOHAVERSION,
403
                                "kohaversion" => Koha::version(),
402
                                );
404
                                );
403
            }
405
            }
404
        }
406
        }
(-)a/kohaversion.pl (-16 / +3 lines)
Lines 1-23 Link Here
1
# the next koha public release version number;
1
# the next koha public release version number;
2
2
3
=head1 FUNCTIONS
3
use Modern::Perl;
4
4
use Koha;
5
=head2 kohaversion
6
7
the kohaversion is divided in 4 parts :
8
 - #1 : the major number. 3 atm
9
 - #2 : the functional release. 00 atm
10
 - #3 : the subnumber, moves only on a public release
11
 - #4 : the developer version. The 4th number is the database subversion.
12
        used by developers when the database changes. updatedatabase take care of the changes itself
13
        and is automatically called by Auth.pm when needed.
14
15
=cut
16
17
use strict;
18
5
19
sub kohaversion {
6
sub kohaversion {
20
    our $VERSION = '3.19.00.031';
7
    our $VERSION = $Koha::VERSION;
21
    # version needs to be set this way
8
    # version needs to be set this way
22
    # so that it can be picked up by Makefile.PL
9
    # so that it can be picked up by Makefile.PL
23
    # during install
10
    # during install
(-)a/opac/maintenance.pl (-2 / +4 lines)
Lines 22-32 use C4::Auth; Link Here
22
use C4::Output;
22
use C4::Output;
23
use C4::Templates qw/gettemplate/;
23
use C4::Templates qw/gettemplate/;
24
24
25
use Koha;
26
25
my $query = new CGI;
27
my $query = new CGI;
26
my $template = C4::Templates::gettemplate( 'maintenance.tt', 'opac', $query, 0 );
28
my $template = C4::Templates::gettemplate( 'maintenance.tt', 'opac', $query, 0 );
27
29
28
my $koha_db_version = C4::Context->preference('Version');
30
my $koha_db_version = C4::Context->preference('Version');
29
my $kohaversion     = C4::Context::KOHAVERSION;
31
my $kohaversion     = Koha::version();
30
# Strip dots from version
32
# Strip dots from version
31
$kohaversion     =~ s/\.//g if defined $kohaversion;
33
$kohaversion     =~ s/\.//g if defined $kohaversion;
32
$koha_db_version =~ s/\.//g if defined $koha_db_version;
34
$koha_db_version =~ s/\.//g if defined $koha_db_version;
Lines 40-43 else { Link Here
40
    print $query->redirect("/cgi-bin/koha/opac-main.pl");
42
    print $query->redirect("/cgi-bin/koha/opac-main.pl");
41
}
43
}
42
44
43
1;
45
1;
(-)a/opac/svc/overdrive_proxy (-1 / +3 lines)
Lines 42-47 use C4::Context; Link Here
42
use C4::External::OverDrive;
42
use C4::External::OverDrive;
43
use C4::Output;
43
use C4::Output;
44
44
45
use Koha;
46
45
my $query = new CGI;
47
my $query = new CGI;
46
48
47
my $token;
49
my $token;
Lines 62-68 if ( !IsOverDriveEnabled() || !( $token = GetOverDriveToken() ) ) { Link Here
62
my $request = HTTP::Request::Common::GET( "https://api.overdrive.com/v1" . $query->path_info . '?' . $query->query_string );
64
my $request = HTTP::Request::Common::GET( "https://api.overdrive.com/v1" . $query->path_info . '?' . $query->query_string );
63
$request->header( Authorization => $token );
65
$request->header( Authorization => $token );
64
66
65
my $ua = LWP::UserAgent->new( "Koha " . C4::Context->KOHAVERSION );
67
my $ua = LWP::UserAgent->new( "Koha " . Koha::version() );
66
68
67
my $response = $ua->request( $request ) ;
69
my $response = $ua->request( $request ) ;
68
if ( $response->code eq '500' ) {
70
if ( $response->code eq '500' ) {
(-)a/t/Koha_Template_Plugin_Koha.t (-7 / +7 lines)
Lines 26-44 use String::Random; Link Here
26
use_ok( 'Koha::Template::Plugin::Koha' );
26
use_ok( 'Koha::Template::Plugin::Koha' );
27
ok( my $cache = Koha::Template::Plugin::Koha->new() );
27
ok( my $cache = Koha::Template::Plugin::Koha->new() );
28
28
29
subtest "Koha::Template::Plugin::Koha::Version tests" => sub {
29
subtest "Koha::Template::Plugin::Koha::version tests" => sub {
30
30
31
    plan tests => 2;
31
    plan tests => 2;
32
32
33
    # Variables for mocking KOHAVERSION
33
    # Variables for mocking Koha::version()
34
    my $major;
34
    my $major;
35
    my $minor;
35
    my $minor;
36
    my $maintenance;
36
    my $maintenance;
37
    my $development;
37
    my $development;
38
38
39
    # Mock C4::Context::KOHAVERSION
39
    # Mock Koha::version()
40
    my $context = new Test::MockModule('C4::Context');
40
    my $koha = new Test::MockModule('Koha');
41
    $context->mock( 'KOHAVERSION', sub {
41
    $koha->mock( 'Version', sub {
42
        return "$major.$minor.$maintenance.$development";
42
        return "$major.$minor.$maintenance.$development";
43
    });
43
    });
44
44
Lines 49-55 subtest "Koha::Template::Plugin::Koha::Version tests" => sub { Link Here
49
    $maintenance = $rnd->randregex('\d\d');
49
    $maintenance = $rnd->randregex('\d\d');
50
    $development = $rnd->randregex('\d\d\d');
50
    $development = $rnd->randregex('\d\d\d');
51
    my $version = "$major.$minor.$maintenance.$development";
51
    my $version = "$major.$minor.$maintenance.$development";
52
    my $res = Koha::Template::Plugin::Koha::Version( $version );
52
    my $res = Koha::Template::Plugin::Koha::version( $version );
53
    is_deeply( $res, {
53
    is_deeply( $res, {
54
        major       => $major,
54
        major       => $major,
55
        release     => $major . "." . $minor,
55
        release     => $major . "." . $minor,
Lines 64-70 subtest "Koha::Template::Plugin::Koha::Version tests" => sub { Link Here
64
    $maintenance = $rnd->randregex('\d\d');
64
    $maintenance = $rnd->randregex('\d\d');
65
    $development = "000";
65
    $development = "000";
66
    $version = "$major.$minor.$maintenance.$development";
66
    $version = "$major.$minor.$maintenance.$development";
67
    $res = Koha::Template::Plugin::Koha::Version( $version );
67
    $res = Koha::Template::Plugin::Koha::version( $version );
68
    is_deeply( $res, {
68
    is_deeply( $res, {
69
        major       => $major,
69
        major       => $major,
70
        release     => $major . "." . $minor,
70
        release     => $major . "." . $minor,
(-)a/t/db_dependent/Context.t (-8 lines)
Lines 20-32 BEGIN { Link Here
20
20
21
ok($koha = C4::Context->new,  'C4::Context->new');
21
ok($koha = C4::Context->new,  'C4::Context->new');
22
ok($dbh = C4::Context->dbh(), 'Getting dbh from C4::Context');
22
ok($dbh = C4::Context->dbh(), 'Getting dbh from C4::Context');
23
ok($ret = C4::Context->KOHAVERSION, '  (function)  KOHAVERSION = ' . ($ret||''));
24
ok($ret =       $koha->KOHAVERSION, '       $koha->KOHAVERSION = ' . ($ret||''));
25
ok(
26
    TransformVersionToNum( C4::Context->final_linear_version ) <=
27
      TransformVersionToNum( C4::Context->KOHAVERSION ),
28
    'Final linear version is less than or equal to kohaversion.pl'
29
);
30
my @keys = keys %$koha;
23
my @keys = keys %$koha;
31
my $width = 0;
24
my $width = 0;
32
if (ok(@keys)) { 
25
if (ok(@keys)) { 
33
- 

Return to bug 13758