It will permit not to run another perl interpreter.
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
use C4::Languages;
use C4::Branch; # GetBranches
use C4::Search::History;
+use Koha;
use Koha::AuthUtils qw(hash_password);
use POSIX qw/strftime/;
use List::MoreUtils qw/ any /;
# there is no DB version, it's a fresh install,
# go to web installer
# there is a DB version, compare it to the code version
- my $kohaversion = C4::Context::KOHAVERSION;
+ my $kohaversion = Koha::version();
# remove the 3 last . to have a Perl number
$kohaversion =~ s/(.*\..*)\.(.*)\.(.*)/$1$2$3/;
# database has not been installed yet
return ( "maintenance", undef, undef );
}
- my $kohaversion = C4::Context::KOHAVERSION;
+ my $kohaversion = Koha::version();
$kohaversion =~ s/(.*\..*)\.(.*)\.(.*)/$1$2$3/;
if ( C4::Context->preference('Version') < $kohaversion ) {
# database has not been installed yet
return ( "maintenance", undef );
}
- my $kohaversion = C4::Context::KOHAVERSION;
+ my $kohaversion = Koha::version();
$kohaversion =~ s/(.*\..*)\.(.*)\.(.*)/$1$2$3/;
if ( C4::Context->preference('Version') < $kohaversion ) {
use XML::Simple;
use C4::Boolean;
use C4::Debug;
+use Koha;
use POSIX ();
use DateTime::TimeZone;
use Module::Load::Conditional qw(can_load);
@context_stack = (); # Initially, no saved contexts
-=head2 KOHAVERSION
-
-returns the kohaversion stored in kohaversion.pl file
-
-=cut
-
-sub KOHAVERSION {
- my $cgidir = C4::Context->intranetdir;
-
- # Apparently the GIT code does not run out of a CGI-BIN subdirectory
- # but distribution code does? (Stan, 1jan08)
- if(-d $cgidir . "/cgi-bin"){
- my $cgidir .= "/cgi-bin";
- }
-
- do $cgidir."/kohaversion.pl" || die "NO $cgidir/kohaversion.pl";
- return kohaversion();
-}
-
-=head2 final_linear_version
-
-Returns the version number of the final update to run in updatedatabase.pl.
-This number is equal to the version in kohaversion.pl
-
-=cut
-
-sub final_linear_version {
- return KOHAVERSION;
-}
-
=head2 read_config_file
Reads the specified Koha config file.
# A little example sub to show more debugging info for CGI::Carp
sub get_versions {
my %versions;
- $versions{kohaVersion} = KOHAVERSION();
+ $versions{kohaVersion} = Koha::version();
$versions{kohaDbVersion} = C4::Context->preference('version');
$versions{osVersion} = join(" ", POSIX::uname());
$versions{perlVersion} = $];
use strict;
use warnings;
+use Koha;
use JSON;
use Koha::Cache;
use HTTP::Request;
sub _request {
my ( $request ) = @_;
- my $ua = LWP::UserAgent->new( "Koha " . C4::Context->KOHAVERSION );
+ my $ua = LWP::UserAgent->new( "Koha " . $KOHA::VERSION );
my $response;
eval {
our $VERSION = 3.07.00.049;
use C4::Context;
use C4::Installer::PerlModules;
+use Koha;
=head1 NAME
sub set_version_syspref {
my $self = shift;
- my $kohaversion=C4::Context::KOHAVERSION;
+ my $kohaversion = Koha::version();
# remove the 3 last . to have a Perl number
$kohaversion =~ s/(.*\..*)\.(.*)\.(.*)/$1$2$3/;
if (C4::Context->preference('Version')) {
--- /dev/null
+package Koha;
+
+use Modern::Perl;
+
+use vars qw{ $VERSION };
+
+#the kohaversion is divided in 4 parts :
+# - #1 : the major number. 3 atm
+# - #2 : the functional release. 00 atm
+# - #3 : the subnumber, moves only on a public release
+# - #4 : the developer version. The 4th number is the database subversion.
+# used by developers when the database changes. updatedatabase take care of the changes itself
+# and is automatically called by Auth.pm when needed.
+$VERSION = "3.19.00.038";
+
+sub version {
+ return $VERSION;
+}
+
+1;
use base qw( Template::Plugin );
use C4::Context;
+use Koha;
=pod
}
sub Version {
- my $version_string = C4::Context::KOHAVERSION;
+ my $version_string = Koha::version();
my ($major,$minor,$maintenance,$development) = split('\.',$version_string);
return {
use C4::Context;
use C4::Installer;
+use Koha;
+
#use Smart::Comments '####';
my $query = new CGI;
}
);
-my $kohaVersion = C4::Context::KOHAVERSION;
+my $kohaVersion = Koha::version();
my $osVersion = `uname -a`;
my $perl_path = $^X;
if ($^O ne 'VMS') {
use C4::Dates;
use Koha::Database;
+use Koha;
+
use MARC::Record;
use MARC::File::XML ( BinaryEncoding => 'utf8' );
return 1 if ( $proposed_version =~ m/XXX/ );
if ( C4::Context->preference("Version") < $version_number
- && $version_number <= TransformToNum( C4::Context->final_linear_version ) )
+ && $version_number <= TransformToNum( $Koha::VERSION ) )
{
return 1;
}
use C4::Languages qw(getAllLanguages getTranslatedLanguages);
use C4::Installer;
+use Koha;
+
my $query = new CGI;
my $step = $query->param('step');
$dbversion = "$1.$2.$3.$4";
$template->param("upgrading" => 1,
"dbversion" => $dbversion,
- "kohaversion" => C4::Context->KOHAVERSION,
+ "kohaversion" => Koha::version(),
);
}
}
# the next koha public release version number;
-=head1 FUNCTIONS
-
-=head2 kohaversion
-
-the kohaversion is divided in 4 parts :
- - #1 : the major number. 3 atm
- - #2 : the functional release. 00 atm
- - #3 : the subnumber, moves only on a public release
- - #4 : the developer version. The 4th number is the database subversion.
- used by developers when the database changes. updatedatabase take care of the changes itself
- and is automatically called by Auth.pm when needed.
-
-=cut
-
-use strict;
+use Modern::Perl;
+use Koha;
sub kohaversion {
- our $VERSION = '3.19.00.038';
+ our $VERSION = $Koha::VERSION;
# version needs to be set this way
# so that it can be picked up by Makefile.PL
# during install
use C4::Output;
use C4::Templates qw/gettemplate/;
+use Koha;
+
my $query = new CGI;
my $template = C4::Templates::gettemplate( 'maintenance.tt', 'opac', $query, 0 );
my $koha_db_version = C4::Context->preference('Version');
-my $kohaversion = C4::Context::KOHAVERSION;
+my $kohaversion = Koha::version();
# Strip dots from version
$kohaversion =~ s/\.//g if defined $kohaversion;
$koha_db_version =~ s/\.//g if defined $koha_db_version;
print $query->redirect("/cgi-bin/koha/opac-main.pl");
}
-1;
\ No newline at end of file
+1;
use C4::External::OverDrive;
use C4::Output;
+use Koha;
+
my $query = new CGI;
my $token;
my $request = HTTP::Request::Common::GET( "https://api.overdrive.com/v1" . $query->path_info . '?' . $query->query_string );
$request->header( Authorization => $token );
-my $ua = LWP::UserAgent->new( "Koha " . C4::Context->KOHAVERSION );
+my $ua = LWP::UserAgent->new( "Koha " . Koha::version() );
my $response = $ua->request( $request ) ;
if ( $response->code eq '500' ) {
use_ok( 'Koha::Template::Plugin::Koha' );
ok( my $cache = Koha::Template::Plugin::Koha->new() );
-subtest "Koha::Template::Plugin::Koha::Version tests" => sub {
+subtest "Koha::Template::Plugin::Koha::version tests" => sub {
plan tests => 2;
- # Variables for mocking KOHAVERSION
+ # Variables for mocking Koha::version()
my $major;
my $minor;
my $maintenance;
my $development;
- # Mock C4::Context::KOHAVERSION
- my $context = new Test::MockModule('C4::Context');
- $context->mock( 'KOHAVERSION', sub {
+ # Mock Koha::version()
+ my $koha = new Test::MockModule('Koha');
+ $koha->mock( 'Version', sub {
return "$major.$minor.$maintenance.$development";
});
$maintenance = $rnd->randregex('\d\d');
$development = $rnd->randregex('\d\d\d');
my $version = "$major.$minor.$maintenance.$development";
- my $res = Koha::Template::Plugin::Koha::Version( $version );
+ my $res = Koha::Template::Plugin::Koha::version( $version );
is_deeply( $res, {
major => $major,
release => $major . "." . $minor,
$maintenance = $rnd->randregex('\d\d');
$development = "000";
$version = "$major.$minor.$maintenance.$development";
- $res = Koha::Template::Plugin::Koha::Version( $version );
+ $res = Koha::Template::Plugin::Koha::version( $version );
is_deeply( $res, {
major => $major,
release => $major . "." . $minor,
ok($koha = C4::Context->new, 'C4::Context->new');
ok($dbh = C4::Context->dbh(), 'Getting dbh from C4::Context');
-ok($ret = C4::Context->KOHAVERSION, ' (function) KOHAVERSION = ' . ($ret||''));
-ok($ret = $koha->KOHAVERSION, ' $koha->KOHAVERSION = ' . ($ret||''));
-ok(
- TransformVersionToNum( C4::Context->final_linear_version ) <=
- TransformVersionToNum( C4::Context->KOHAVERSION ),
- 'Final linear version is less than or equal to kohaversion.pl'
-);
my @keys = keys %$koha;
my $width = 0;
if (ok(@keys)) {