From d004cdef64988163ab88464861649e7680aaac41 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 17 Mar 2015 12:09:12 -0300 Subject: [PATCH] Bug 13758: Koha::Version introduced (counterpatch) This patch introduces a trivial package: Koha::Version. It only contains a constant: VERSION. It is set the current version number. The idea is that we stop relying on calling the kohaversion.pl script to get the current version number. The workfl Sponsored-by: Universidad Nacional de Cordoba --- C4/Context.pm | 16 +++++----------- Koha/Version.pm | 47 +++++++++++++++++++++++++++++++++++++++++++++++ Makefile.PL | 4 ++-- kohaversion.pl | 11 +++++------ 4 files changed, 59 insertions(+), 19 deletions(-) create mode 100644 Koha/Version.pm diff --git a/C4/Context.pm b/C4/Context.pm index cc93af4..8d3d9a2 100644 --- a/C4/Context.pm +++ b/C4/Context.pm @@ -16,8 +16,8 @@ package C4::Context; # with Koha; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -use strict; -use warnings; +use Modern::Perl; + use vars qw($VERSION $AUTOLOAD $context @context_stack $servers $memcached $ismemcached); BEGIN { if ($ENV{'HTTP_USER_AGENT'}) { @@ -107,6 +107,7 @@ use POSIX (); use DateTime::TimeZone; use Module::Load::Conditional qw(can_load); use Carp; +use Koha::Version; =head1 NAME @@ -211,16 +212,9 @@ 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(); + return Koha::Version::VERSION; + } =head2 final_linear_version diff --git a/Koha/Version.pm b/Koha/Version.pm new file mode 100644 index 0000000..4c6b7c3 --- /dev/null +++ b/Koha/Version.pm @@ -0,0 +1,47 @@ +package Koha::Version; + +# Copyright 2015 Theke Solutions +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; + +=head1 NAME + +Koha::Version - A simple package providing the current Koha version + +=head1 SYNOPSIS + + use Koha::Version; + + my $version = Koha::Version::VERSION; + +=cut + +use constant VERSION => '3.19.00.016'; + +1; + +=head1 SEE ALSO + +C4::Context +kohaversion.pl + +=head1 AUTHOR + +Tomas Cohen Arazi + +=cut \ No newline at end of file diff --git a/Makefile.PL b/Makefile.PL index 3af2486..587ff0a 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -1133,8 +1133,8 @@ database to be used by Koha); # add version number my $version = "no_version_found"; eval { - require 'kohaversion.pl'; - $version = kohaversion(); + require Koha::Version; + $version = Koha::Version::VERSION; }; $config{'KOHA_INSTALLED_VERSION'} = $version; diff --git a/kohaversion.pl b/kohaversion.pl index a2769f5..265cb41 100644 --- a/kohaversion.pl +++ b/kohaversion.pl @@ -14,14 +14,13 @@ the kohaversion is divided in 4 parts : =cut -use strict; +use Modern::Perl; +use Koha::Version; sub kohaversion { - our $VERSION = '3.19.00.016'; - # version needs to be set this way - # so that it can be picked up by Makefile.PL - # during install - return $VERSION; + + return Koha::Version::VERSION; + } 1; -- 2.3.3