From b1e4011fa8038e8fde6c11fa30deddee04ad0ffd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Cohen=20Arazi?= Date: Wed, 5 Nov 2025 11:28:59 -0300 Subject: [PATCH] Bug 41107: (follow-up) Use Koha::Status in Koha::Template::Plugin::Koha This patch makes the template plugin used for rendering the Koha version use the introduced method. I did this checks: ```shell cd koha-tmpl git grep Koha.Version ``` The places Koha.Version is used, it is used as: * `Koha.Version.maintenance` * `Koha.Version.release` * Assigned to a variable like this `SET koha_version = Koha.Version` All occurences of the `koha_version` template variable are: * `koha_version.development` * `koha_version.major` * `koha_version.minor` This implies the newly added `.version` attribute has no undesired side effects in templates. Note: plugins-home.tt has a different use of a variable named the same, which is unrelated. To test: 1. Apply this patch 2. Run: $ ktd --shell k$ prove t/Koha_Template_Plugin_Koha.t => SUCCESS: Tests pass! 3. Sign off :-D Signed-off-by: David Nind --- Koha/Template/Plugin/Koha.pm | 12 ++---------- t/Koha_Template_Plugin_Koha.t | 6 ++++-- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Koha/Template/Plugin/Koha.pm b/Koha/Template/Plugin/Koha.pm index 11ed0cecf3..2a65608da7 100644 --- a/Koha/Template/Plugin/Koha.pm +++ b/Koha/Template/Plugin/Koha.pm @@ -24,6 +24,7 @@ use base qw( Template::Plugin ); use C4::Context; use Koha::Token; use Koha; +use Koha::Status; use Koha::Cache::Memory::Lite; =head1 NAME @@ -110,16 +111,7 @@ Missing POD for Version. =cut sub Version { - my $version_string = Koha::version(); - my ( $major, $minor, $maintenance, $development ) = split( '\.', $version_string ); - - return { - major => $major, - minor => $minor, - release => $major . "." . $minor, - maintenance => $major . "." . $minor . "." . $maintenance, - development => ( $development ne '000' ) ? $development : undef, - }; + return Koha::Status->new()->version(); } =head3 GenerateCSRF diff --git a/t/Koha_Template_Plugin_Koha.t b/t/Koha_Template_Plugin_Koha.t index 99baa31ab5..c16bbd4e8c 100755 --- a/t/Koha_Template_Plugin_Koha.t +++ b/t/Koha_Template_Plugin_Koha.t @@ -63,7 +63,8 @@ subtest "Koha::Template::Plugin::Koha::Version tests" => sub { minor => $minor, release => $major . "." . $minor, maintenance => $major . "." . $minor . "." . $maintenance, - development => $development + development => $development, + version => $version, }, "Correct development version" ); @@ -82,7 +83,8 @@ subtest "Koha::Template::Plugin::Koha::Version tests" => sub { minor => $minor, release => $major . "." . $minor, maintenance => $major . "." . $minor . "." . $maintenance, - development => undef + development => undef, + version => $version, }, "Correct maintenance version" ); -- 2.39.5