Bug 39934

Summary: Standard backend shows attributes from previously "migrated from" backends
Product: Koha Reporter: Pedro Amorim <pedro.amorim>
Component: ILLAssignee: Pedro Amorim <pedro.amorim>
Status: Signed Off --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: david, katrin.fischer, lisette, martin.renvoize, pedro.amorim, tomascohen
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38341
GIT URL: Initiative type: ---
Sponsorship status: --- Comma delimited list of Sponsors:
Crowdfunding goal: 0 Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Bug 39934: Only fetch attributes from 'Standard'
Bug 39934: Use _get_core_fields as fields to be migrated
Bug 39934: Add tests
Bug 39934: Only fetch attributes from 'Standard'
Bug 39934: Use _get_core_fields as fields to be migrated
Bug 39934: Add tests
Bug 39934: Only fetch attributes from 'Standard'
Bug 39934: Use _get_core_fields as fields to be migrated
Bug 39934: Add tests

Description Pedro Amorim 2025-05-19 10:36:45 UTC

    
Comment 1 Pedro Amorim 2025-05-19 10:44:39 UTC
Created attachment 182581 [details] [review]
Bug 39934: Only fetch attributes from 'Standard'

Furthermore, this now only shows metadata present in _get_core_fields,
so a list of attributes to ignore is not longer needed (they're not in
_get_core_fields).
Comment 2 Pedro Amorim 2025-05-19 10:44:42 UTC
Created attachment 182582 [details] [review]
Bug 39934: Use _get_core_fields as fields to be migrated

Instead of ignoring from an arbitrary list
Comment 3 Pedro Amorim 2025-05-19 10:44:44 UTC
Created attachment 182583 [details] [review]
Bug 39934: Add tests

prove t/db_dependent/Koha/ILL/Backend/Standard.t

Test plan, k-t-d, don't apply patches yet:
1) Enable ILLModule sys pref
2) Install an additional backend, e.g. ReprintsDesk:
https://github.com/openfifth/koha-ill-reprintsdesk/releases/tag/v3.0.2
3) Restart plack
$ koha-plack --restart kohadev
4) Create a new ReprintsDesk request, visit:
<staff_url>/cgi-bin/koha/ill/ill-requests.pl?method=create&backend=ReprintsDesk
5) Enter DOI: '123', EISSN: 'abc', a cardnumber '42' and a library. Click 'Make request'
6) Click 'Switch provider'. Pick 'Standard'.
7) Notice 'Eissn' shows. This is confusing as it means nothing in the 'Standard' context. 'Migrated from' is also shown and is equally as confusing for staff members (This is a remnant of previous behavior when migrating a request would create a new request).
8) Apply patches. Repeat test plan. The attributes from the previous backend still exist in the database, but the UI now only shows attributes relevant to the current backend of the request. To confirm this, run:
$ koha-mysql kohadev
$ select * from illrequestattributes;
Comment 4 Pedro Amorim 2025-09-23 15:30:48 UTC
Hi @Tomas. Patch still applies for me on current main, can you please double-check? Thank you.
Comment 5 Pedro Amorim 2025-09-23 15:31:51 UTC
Adding others here if anyone fancies testing as it's been on 'Needs Sign-off' for 4 months now.
Comment 6 David Nind 2026-01-03 19:45:53 UTC
The patches no longer apply 8-(...

git bz apply 39934

Bug 39934 - Standard backend shows attributes from previously "migrated from" backends

182581 - Bug 39934: Only fetch attributes from 'Standard'
182582 - Bug 39934: Use _get_core_fields as fields to be migrated
182583 - Bug 39934: Add tests

Apply? [(y)es, (n)o, (i)nteractive] y
Applying: Bug 39934: Only fetch attributes from 'Standard'
Using index info to reconstruct a base tree...
M	Koha/ILL/Backend/Standard.pm
Falling back to patching base and 3-way merge...
Auto-merging Koha/ILL/Backend/Standard.pm
CONFLICT (content): Merge conflict in Koha/ILL/Backend/Standard.pm
error: Failed to merge in the changes.
Patch failed at 0001 Bug 39934: Only fetch attributes from 'Standard'

Testing notes (using KTD):

1. For step 2, I downloaded the 3.0.2 version of the plugin (if I searched for it, v2.0.5 was the only result, I didn't use the latest as that required applying naother bug).
Comment 7 Pedro Amorim 2026-01-05 13:24:04 UTC
Created attachment 190887 [details] [review]
Bug 39934: Only fetch attributes from 'Standard'
Comment 8 Pedro Amorim 2026-01-05 13:24:07 UTC
Created attachment 190888 [details] [review]
Bug 39934: Use _get_core_fields as fields to be migrated

Also add backend check to add_or_update_attributes
Comment 9 Pedro Amorim 2026-01-05 13:24:10 UTC
Created attachment 190889 [details] [review]
Bug 39934: Add tests

prove t/db_dependent/Koha/ILL/Backend/Standard.t

Test plan, k-t-d, don't apply patches yet:
1) Enable ILLModule sys pref
2) Install an additional backend, e.g. ReprintsDesk:
https://github.com/openfifth/koha-ill-reprintsdesk/releases/tag/v4.0.3
3) Restart plack
$ koha-plack --restart kohadev
4) Create a new ReprintsDesk request, visit:
<staff_url>/cgi-bin/koha/ill/ill-requests.pl?method=create&backend=ReprintsDesk
5) Enter DOI: '123', 'First page of article in journal': 'abc', a cardnumber '42' and a library. Click 'Make request'
6) Click 'Switch provider'. Pick 'Standard'.
7) Notice 'First page of article in journal' shows. This is confusing as it means nothing in the 'Standard' context.
8) Apply patches. Repeat test plan. The attributes from the previous backend still exist in the database, but the UI now only shows attributes relevant to the current backend of the request. To confirm this, run:
$ koha-mysql kohadev
$ select * from illrequestattributes;
Comment 10 David Nind 2026-01-05 18:56:47 UTC
Created attachment 190908 [details] [review]
Bug 39934: Only fetch attributes from 'Standard'

Signed-off-by: David Nind <david@davidnind.com>
Comment 11 David Nind 2026-01-05 18:56:51 UTC
Created attachment 190909 [details] [review]
Bug 39934: Use _get_core_fields as fields to be migrated

Also add backend check to add_or_update_attributes

Signed-off-by: David Nind <david@davidnind.com>
Comment 12 David Nind 2026-01-05 18:56:54 UTC
Created attachment 190910 [details] [review]
Bug 39934: Add tests

prove t/db_dependent/Koha/ILL/Backend/Standard.t

Test plan, k-t-d, don't apply patches yet:
1) Enable ILLModule sys pref
2) Install an additional backend, e.g. ReprintsDesk:
https://github.com/openfifth/koha-ill-reprintsdesk/releases/tag/v4.0.3
3) Restart plack
$ koha-plack --restart kohadev
4) Create a new ReprintsDesk request, visit:
<staff_url>/cgi-bin/koha/ill/ill-requests.pl?method=create&backend=ReprintsDesk
5) Enter DOI: '123', 'First page of article in journal': 'abc', a cardnumber '42' and a library. Click 'Make request'
6) Click 'Switch provider'. Pick 'Standard'.
7) Notice 'First page of article in journal' shows. This is confusing as it means nothing in the 'Standard' context.
8) Apply patches. Repeat test plan. The attributes from the previous backend still exist in the database, but the UI now only shows attributes relevant to the current backend of the request. To confirm this, run:
$ koha-mysql kohadev
$ select * from illrequestattributes;

Signed-off-by: David Nind <david@davidnind.com>