Bug 39932

Summary: Koha::Item->_status should return an array
Product: Koha Reporter: Tomás Cohen Arazi (tcohen) <tomascohen>
Component: REST APIAssignee: Tomás Cohen Arazi (tcohen) <tomascohen>
Status: Passed QA --- QA Contact: Martin Renvoize (ashimema) <martin.renvoize>
Severity: major    
Priority: P5 - low CC: jonathan.druart, lucas, martin.renvoize, tomascohen
Version: MainKeywords: rel_25_05_candidate
Hardware: All   
OS: All   
GIT URL: Change sponsored?: ---
Patch complexity: Small patch Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
Circulation function:
Bug Depends on: 37334    
Bug Blocks:    
Attachments: Bug 39932: Make Koha::Item->_status return an arrayref
Bug 39932: Add POD for Koha::Item->_status()
Bug 39932: Remove split in template
Bug 39932: Make Koha::Item->_status return an arrayref
Bug 39932: Add POD for Koha::Item->_status()
Bug 39932: Remove split in template
Bug 39932: Make Koha::Item->_status return an arrayref
Bug 39932: Add POD for Koha::Item->_status()
Bug 39932: Remove split in template

Description Tomás Cohen Arazi (tcohen) 2025-05-17 12:21:49 UTC
The `_status` method has a couple problems:

* It doesn't have a POD
* It returns a string!

It should return a list instead, so handling on the UI doesn't require splitting the string back.

That said, the tests using it in the UI (Holdings_spec.ts) only test the `available` rendering use case. This is minor.
Comment 1 Tomás Cohen Arazi (tcohen) 2025-05-17 12:22:25 UTC
I think this should be fixed for the release.
Comment 2 Tomás Cohen Arazi (tcohen) 2025-05-19 12:15:10 UTC
Created attachment 182598 [details] [review]
Bug 39932: Make Koha::Item->_status return an arrayref

This patch makes the method return an actual array instead of a
comma-separated string. The API spec is adjusted so it also expects an
array in the response.

Tests are adjusted for the new return value.

To test:
1. Apply this patch
2. Run:
   $ ktd --shell
  k$ yarn api:bundle
  k$ prove t/db_dependent/Koha/Item.t
=> SUCCESS: Tests pass!
3. Sign off :-D
Comment 3 Tomás Cohen Arazi (tcohen) 2025-05-19 12:15:12 UTC
Created attachment 182599 [details] [review]
Bug 39932: Add POD for Koha::Item->_status()

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 4 Tomás Cohen Arazi (tcohen) 2025-05-19 12:15:15 UTC
Created attachment 182600 [details] [review]
Bug 39932: Remove split in template
Comment 5 Tomás Cohen Arazi (tcohen) 2025-05-19 12:18:33 UTC
I marked it as Major to get more attention. I think the API spec is the most sensible issue here, as people could start using the 'string value' once it is published.
Comment 6 David Nind 2025-05-19 13:59:40 UTC
Created attachment 182605 [details] [review]
Bug 39932: Make Koha::Item->_status return an arrayref

This patch makes the method return an actual array instead of a
comma-separated string. The API spec is adjusted so it also expects an
array in the response.

Tests are adjusted for the new return value.

To test:
1. Apply this patch
2. Run:
   $ ktd --shell
  k$ yarn api:bundle
  k$ prove t/db_dependent/Koha/Item.t
=> SUCCESS: Tests pass!
3. Sign off :-D

Signed-off-by: David Nind <david@davidnind.com>
Comment 7 David Nind 2025-05-19 13:59:43 UTC
Created attachment 182606 [details] [review]
Bug 39932: Add POD for Koha::Item->_status()

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: David Nind <david@davidnind.com>
Comment 8 David Nind 2025-05-19 13:59:45 UTC
Created attachment 182607 [details] [review]
Bug 39932: Remove split in template

Signed-off-by: David Nind <david@davidnind.com>
Comment 9 Martin Renvoize (ashimema) 2025-05-19 18:04:14 UTC
Created attachment 182632 [details] [review]
Bug 39932: Make Koha::Item->_status return an arrayref

This patch makes the method return an actual array instead of a
comma-separated string. The API spec is adjusted so it also expects an
array in the response.

Tests are adjusted for the new return value.

To test:
1. Apply this patch
2. Run:
   $ ktd --shell
  k$ yarn api:bundle
  k$ prove t/db_dependent/Koha/Item.t
=> SUCCESS: Tests pass!
3. Sign off :-D

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Comment 10 Martin Renvoize (ashimema) 2025-05-19 18:04:18 UTC
Created attachment 182633 [details] [review]
Bug 39932: Add POD for Koha::Item->_status()

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Comment 11 Martin Renvoize (ashimema) 2025-05-19 18:04:21 UTC
Created attachment 182634 [details] [review]
Bug 39932: Remove split in template

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>