Bug 41107

Summary: Create an API endpoint to get Koha version
Product: Koha Reporter: Andrew Fuerste-Henry <andrew>
Component: REST APIAssignee: Tomás Cohen Arazi (tcohen) <tomascohen>
Status: Signed Off --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: dcook, mike.grgurev, tomascohen
Version: Main   
Hardware: All   
OS: All   
GIT URL: Initiative type: ---
Sponsorship status: --- Comma delimited list of Sponsors:
Crowdfunding goal: 0 Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Bug 41107: Add /status/version API endpoint
Bug 41107: (follow-up) Use Koha::Status in Koha::Template::Plugin::Koha
Bug 41107: Add /status/version API endpoint
Bug 41107: (follow-up) Use Koha::Status in Koha::Template::Plugin::Koha

Description Andrew Fuerste-Henry 2025-10-27 13:28:11 UTC
It would be helpful to have an API endpoint from which to get the Koha version of a system
Comment 1 Tomás Cohen Arazi (tcohen) 2025-11-05 14:39:51 UTC
Created attachment 189072 [details] [review]
Bug 41107: Add /status/version API endpoint

Adds a new REST API endpoint to retrieve Koha version information.

This implementation includes:
- Koha::Status class for instance status information
- /status/version endpoint returning structured version data
- OpenAPI specification with koha_version definition
- REST controller for handling the endpoint

The returned version object includes:
- version: full version string (e.g., '25.06.00.029')
- major: major version number
- minor: minor version number
- release: major.minor version
- maintenance: major.minor.maintenance version
- development: development version (if applicable)

This prepares the foundation for a future /status endpoint that will
include all information displayed in the about page.

To test:
1. Apply the patch
2. Run:
   $ ktd --shell
  k$ yarn api:bundle
3. Run the tests:
  k$ prove t/Koha/Status.t \
           t/db_dependent/api/v1/status.t
=> SUCCESS: Tests pass!
4. Sign off :-D
Comment 2 Tomás Cohen Arazi (tcohen) 2025-11-05 14:39:54 UTC
Created attachment 189073 [details] [review]
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
Comment 3 David Nind 2025-11-28 21:46:17 UTC
Created attachment 190029 [details] [review]
Bug 41107: Add /status/version API endpoint

Adds a new REST API endpoint to retrieve Koha version information.

This implementation includes:
- Koha::Status class for instance status information
- /status/version endpoint returning structured version data
- OpenAPI specification with koha_version definition
- REST controller for handling the endpoint

The returned version object includes:
- version: full version string (e.g., '25.06.00.029')
- major: major version number
- minor: minor version number
- release: major.minor version
- maintenance: major.minor.maintenance version
- development: development version (if applicable)

This prepares the foundation for a future /status endpoint that will
include all information displayed in the about page.

To test:
1. Apply the patch
2. Run:
   $ ktd --shell
  k$ yarn api:bundle
3. Run the tests:
  k$ prove t/Koha/Status.t \
           t/db_dependent/api/v1/status.t
=> SUCCESS: Tests pass!
4. Sign off :-D

Signed-off-by: David Nind <david@davidnind.com>
Comment 4 David Nind 2025-11-28 21:46:21 UTC
Created attachment 190030 [details] [review]
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>