Bugzilla – Attachment 38738 Details for
Bug 13758
KOHAVERSION should be statically set
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[PASSED QA] Bug 13758: Move the Koha version from kohaversion.pl
PASSED-QA-Bug-13758-Move-the-Koha-version-from-koh.patch (text/plain), 13.37 KB, created by
Kyle M Hall (khall)
on 2015-05-01 13:20:19 UTC
(
hide
)
Description:
[PASSED QA] Bug 13758: Move the Koha version from kohaversion.pl
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2015-05-01 13:20:19 UTC
Size:
13.37 KB
patch
obsolete
>From 7ccf23547b9ab7576ece6c90f7dda54550d0eba3 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Tue, 17 Mar 2015 16:02:41 +0100 >Subject: [PATCH] [PASSED QA] Bug 13758: Move the Koha version from kohaversion.pl > >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> >--- > C4/Auth.pm | 7 +++-- > C4/Context.pm | 33 +------------------------------ > C4/External/OverDrive.pm | 3 +- > C4/Installer.pm | 3 +- > Koha.pm | 20 +++++++++++++++++++ > Koha/Template/Plugin/Koha.pm | 3 +- > about.pl | 4 ++- > installer/data/mysql/updatedatabase.pl | 4 ++- > installer/install.pl | 4 ++- > kohaversion.pl | 19 ++--------------- > opac/maintenance.pl | 6 +++- > opac/svc/overdrive_proxy | 4 ++- > t/Koha_Template_Plugin_Koha.t | 14 ++++++------ > t/db_dependent/Context.t | 7 ------ > 14 files changed, 58 insertions(+), 73 deletions(-) > create mode 100644 Koha.pm > >diff --git a/C4/Auth.pm b/C4/Auth.pm >index 4b02701..9a5d6b4 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -30,6 +30,7 @@ use C4::Templates; # to get the template > 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 /; >@@ -662,7 +663,7 @@ sub _version_check { > # 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/; >@@ -1311,7 +1312,7 @@ sub check_api_auth { > # 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 ) { > >@@ -1565,7 +1566,7 @@ sub check_cookie_auth { > # 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 ) { > >diff --git a/C4/Context.pm b/C4/Context.pm >index 42e7aa2..a51f5c7 100644 >--- a/C4/Context.pm >+++ b/C4/Context.pm >@@ -103,6 +103,7 @@ use ZOOM; > use XML::Simple; > use C4::Boolean; > use C4::Debug; >+use Koha; > use POSIX (); > use DateTime::TimeZone; > use Module::Load::Conditional qw(can_load); >@@ -204,36 +205,6 @@ $context = undef; # Initially, no context is set > @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. >@@ -1199,7 +1170,7 @@ Gets various version info, for core Koha packages, Currently called from carp ha > # 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} = $]; >diff --git a/C4/External/OverDrive.pm b/C4/External/OverDrive.pm >index bed0d55..338dd76 100644 >--- a/C4/External/OverDrive.pm >+++ b/C4/External/OverDrive.pm >@@ -20,6 +20,7 @@ package C4::External::OverDrive; > use strict; > use warnings; > >+use Koha; > use JSON; > use Koha::Cache; > use HTTP::Request; >@@ -39,7 +40,7 @@ BEGIN { > > sub _request { > my ( $request ) = @_; >- my $ua = LWP::UserAgent->new( "Koha " . C4::Context->KOHAVERSION ); >+ my $ua = LWP::UserAgent->new( "Koha " . $KOHA::VERSION ); > > my $response; > eval { >diff --git a/C4/Installer.pm b/C4/Installer.pm >index 0ccde90..d15be1f 100644 >--- a/C4/Installer.pm >+++ b/C4/Installer.pm >@@ -24,6 +24,7 @@ use Encode qw( encode is_utf8 ); > our $VERSION = 3.07.00.049; > use C4::Context; > use C4::Installer::PerlModules; >+use Koha; > > =head1 NAME > >@@ -389,7 +390,7 @@ Koha software version. > 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')) { >diff --git a/Koha.pm b/Koha.pm >new file mode 100644 >index 0000000..f5da04d >--- /dev/null >+++ b/Koha.pm >@@ -0,0 +1,20 @@ >+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.031"; >+ >+sub version { >+ return $VERSION; >+} >+ >+1; >diff --git a/Koha/Template/Plugin/Koha.pm b/Koha/Template/Plugin/Koha.pm >index 7d562e7..ecb6266 100644 >--- a/Koha/Template/Plugin/Koha.pm >+++ b/Koha/Template/Plugin/Koha.pm >@@ -23,6 +23,7 @@ use Encode qw( encode ); > use base qw( Template::Plugin ); > > use C4::Context; >+use Koha; > > =pod > >@@ -46,7 +47,7 @@ sub Preference { > } > > sub Version { >- my $version_string = C4::Context::KOHAVERSION; >+ my $version_string = Koha::version(); > my ($major,$minor,$maintenance,$development) = split('\.',$version_string); > > return { >diff --git a/about.pl b/about.pl >index 709a667..969e8fd 100755 >--- a/about.pl >+++ b/about.pl >@@ -33,6 +33,8 @@ use C4::Auth; > use C4::Context; > use C4::Installer; > >+use Koha; >+ > #use Smart::Comments '####'; > > my $query = new CGI; >@@ -47,7 +49,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > } > ); > >-my $kohaVersion = C4::Context::KOHAVERSION; >+my $kohaVersion = Koha::version(); > my $osVersion = `uname -a`; > my $perl_path = $^X; > if ($^O ne 'VMS') { >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 128d8ad..9b872a4 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -39,6 +39,8 @@ use C4::Installer; > use C4::Dates; > use Koha::Database; > >+use Koha; >+ > use MARC::Record; > use MARC::File::XML ( BinaryEncoding => 'utf8' ); > >@@ -10447,7 +10449,7 @@ sub CheckVersion { > 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; > } >diff --git a/installer/install.pl b/installer/install.pl >index 1fbc685..6b56777 100755 >--- a/installer/install.pl >+++ b/installer/install.pl >@@ -14,6 +14,8 @@ use C4::Templates; > use C4::Languages qw(getAllLanguages getTranslatedLanguages); > use C4::Installer; > >+use Koha; >+ > my $query = new CGI; > my $step = $query->param('step'); > >@@ -398,7 +400,7 @@ elsif ( $step && $step == 3 ) { > $dbversion = "$1.$2.$3.$4"; > $template->param("upgrading" => 1, > "dbversion" => $dbversion, >- "kohaversion" => C4::Context->KOHAVERSION, >+ "kohaversion" => Koha::version(), > ); > } > } >diff --git a/kohaversion.pl b/kohaversion.pl >index 3bd5475..d215634 100644 >--- a/kohaversion.pl >+++ b/kohaversion.pl >@@ -1,23 +1,10 @@ > # 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.035'; >+ our $VERSION = $Koha::VERSION; > # version needs to be set this way > # so that it can be picked up by Makefile.PL > # during install >diff --git a/opac/maintenance.pl b/opac/maintenance.pl >index 2a1cad8..1839e2e 100755 >--- a/opac/maintenance.pl >+++ b/opac/maintenance.pl >@@ -22,11 +22,13 @@ use C4::Auth; > 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; >@@ -40,4 +42,4 @@ else { > print $query->redirect("/cgi-bin/koha/opac-main.pl"); > } > >-1; >\ No newline at end of file >+1; >diff --git a/opac/svc/overdrive_proxy b/opac/svc/overdrive_proxy >index 22f4b1b..fdddbbb 100755 >--- a/opac/svc/overdrive_proxy >+++ b/opac/svc/overdrive_proxy >@@ -42,6 +42,8 @@ use C4::Context; > use C4::External::OverDrive; > use C4::Output; > >+use Koha; >+ > my $query = new CGI; > > my $token; >@@ -62,7 +64,7 @@ if ( !IsOverDriveEnabled() || !( $token = GetOverDriveToken() ) ) { > 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' ) { >diff --git a/t/Koha_Template_Plugin_Koha.t b/t/Koha_Template_Plugin_Koha.t >index e22e0d8..50c198f 100644 >--- a/t/Koha_Template_Plugin_Koha.t >+++ b/t/Koha_Template_Plugin_Koha.t >@@ -26,19 +26,19 @@ use String::Random; > 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"; > }); > >@@ -49,7 +49,7 @@ subtest "Koha::Template::Plugin::Koha::Version tests" => sub { > $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, >@@ -64,7 +64,7 @@ subtest "Koha::Template::Plugin::Koha::Version tests" => sub { > $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, >diff --git a/t/db_dependent/Context.t b/t/db_dependent/Context.t >index feb2a43..8d93c99 100755 >--- a/t/db_dependent/Context.t >+++ b/t/db_dependent/Context.t >@@ -20,13 +20,6 @@ BEGIN { > > 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)) { >-- >1.7.2.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 13758
:
36951
|
36962
|
36963
|
36988
|
38661
|
38662
|
38663
| 38738 |
38739
|
38952
|
38958
|
38971