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 <david@davidnind.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
This commit is contained in:
Tomás Cohen Arazi 2025-11-05 11:28:59 -03:00 committed by Martin Renvoize
parent 68c8b8f13f
commit f64051cddb
No known key found for this signature in database
GPG Key ID: 2D86E0EAEC83711B
2 changed files with 6 additions and 12 deletions

View File

@ -24,6 +24,7 @@ use base qw( Template::Plugin );
use C4::Context; use C4::Context;
use Koha::Token; use Koha::Token;
use Koha; use Koha;
use Koha::Status;
use Koha::Cache::Memory::Lite; use Koha::Cache::Memory::Lite;
use Koha::ContentSecurityPolicy; use Koha::ContentSecurityPolicy;
@ -131,16 +132,7 @@ Missing POD for Version.
=cut =cut
sub Version { sub Version {
my $version_string = Koha::version(); return Koha::Status->new()->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,
};
} }
=head3 GenerateCSRF =head3 GenerateCSRF

View File

@ -63,7 +63,8 @@ subtest "Koha::Template::Plugin::Koha::Version tests" => sub {
minor => $minor, minor => $minor,
release => $major . "." . $minor, release => $major . "." . $minor,
maintenance => $major . "." . $minor . "." . $maintenance, maintenance => $major . "." . $minor . "." . $maintenance,
development => $development development => $development,
version => $version,
}, },
"Correct development version" "Correct development version"
); );
@ -82,7 +83,8 @@ subtest "Koha::Template::Plugin::Koha::Version tests" => sub {
minor => $minor, minor => $minor,
release => $major . "." . $minor, release => $major . "." . $minor,
maintenance => $major . "." . $minor . "." . $maintenance, maintenance => $major . "." . $minor . "." . $maintenance,
development => undef development => undef,
version => $version,
}, },
"Correct maintenance version" "Correct maintenance version"
); );