UNIMARC heading mapping to thesaurus is read from the MARC bibliographic frameworks. On the other hand, MARC21 has them hardcoded in `C4::Heading::MARC21`. This has the side effect of not letting the linker tools honor the linking configuration from the frameworks. For example, if you define your own thesaurus `CEPAL_TOPIC` which you maintain with your own tools/process, and link it to `650$a`, running the linker will still look for `TOPIC_TERM` yielding bad results. We should have an implementation that: * Allows opting in to a UNIMARC-like behavior * Has a fallback mechanism for not-configured mappings so we wouldn't expect behavior change besides the frameworks-defined mappings * It doesn't reinvent the wheel on an old library
Created attachment 192058 [details] [review] Bug 41714: Add system preference Patch from commit 842d8f1
Created attachment 192059 [details] [review] Bug 41714: Add tests Patch from commit ecc86dd
Created attachment 192060 [details] [review] Bug 41714: Add a way to let the authority linker honor frameworks (MARC21) Patch from commit 3058cae
I ran out of time at the desk to write a proper test plan, but wanted to share early so others can see this. You should basically create a new authority type (CUSTOM_TERM), link it to a field, and check the linker doesn't work to link automatically (e.g. 650 is hardcoded to TOPIC_TERM, so it won't find your CUSTOM_TERM heading).
Created attachment 192101 [details] [review] Bug 41714: Add `LinkerUseFrameworkAuthTypes` system preference This patch adds a new syspref for controlling if thesaurus links from teh frameworks should be followed in the MARC21 scenario, or if the hardcoded links should be used (current behavior). The current behavior would be kept.
Created attachment 192102 [details] [review] Bug 41714: Add tests This patch adds tests for the syspref-controlled behavior.
Created attachment 192103 [details] [review] Bug 41714: Add a way to let the authority linker honor frameworks (MARC21) This patchset implements a way to make the authority linker follow the cataloguing frameworks when it comes to linked authority type. The current behavior is this for UNIMARC, but in the MARC21 case it just has hardcoded links (e.g. 650 is always linked to `TOPIC_TERM`). This is accomplished by: * Replicating what UNIMARC does, in MARC21 * Moving the code around so both use the same codebase * Adding tests * Adding the `LinkerUseFrameworkAuthTypes` system preference for opting into this new behavior. To test: 1. Launch a fresh KTD instance: $ ktd --proxy --name authorities --search-engine es9 up -d $ ktd --name authorities --wait-ready 120 2. On the staff interface (http://authorities-admin.localhost) open record 344 3. Change the cataloguing framework to the `Default` one and adjust the details so it can be saved. 4. Edit the `Default` framework to unlink the subfield `650$a` from the `TOPIC_TERM` thesaurus. 5. Go back to editing the record => SUCCESS: Field 650$a can be edited freely (normal behavior for unlinked subfields) 6. Add the following headings to repeatable `650$a`: * YERBA * MATE * BOMBILLA * AGUA CALIENTE 7. Create a new Authority type called `CUST_TERM` in `Admin > Authority types` * Make the 'field to copy' be 150 * Export the `TOPIC_TERM` authority type structure into CSV * Import the exported authority type onto `CUST_TERM` => SUCCESS: `TOPIC_TERM` and `CUST_TERM` are the same thing. 8. Add the following authorities of type `CUST_TERM` * YERBA * MATE * BOMBILLA 9. Edit the `Default` framework so `650$a` is now linked to `CUST_TERM` 10. Run: $ ktd --name authorities --shell k$ perl misc/link_bibs_to_authorities.pl --bib-limit "biblionumber=344" --auth-limit "authtypecode='CUST_TERM'" -l -g 650 => FAIL: You see: ``` Bib authority heading linking report ======================================================= Linker module: C4::Linker::Default Run started at: 01/27/26 14:40:42 Run ended at: 01/27/26 14:40:43 Total run time: 276 ms Number of bibs checked: 1 Number of bibs modified: 0 Number of bibs with errors: 0 Number of headings linked: 1 Number of headings unlinked: 4 Number of headings fuzzily linked: 0 ``` This means it kept the currently linked heading, and the other 4 were kept unliked even though they exist on the `CUST_TERM` thesaurus. 11. Apply this patchset 12. Run: k$ updatedatabase k$ restart_all # just in case => SUCCESS: You see a syspref has been added 13. Repeat 10 => SUCCESS: Same result! 14. Set the `LinkerUseFrameworkAuthTypes` system preference to `Do` 15. Repeat 10: => SUCCESS: Yay! You see: ``` Bib authority heading linking report ======================================================= Linker module: C4::Linker::Default Run started at: 01/27/26 14:41:15 Run ended at: 01/27/26 14:41:16 Total run time: 302 ms Number of bibs checked: 1 Number of bibs modified: 1 Number of bibs with errors: 0 Number of headings linked: 4 Number of headings unlinked: 1 Number of headings fuzzily linked: 0 ``` This means *YERBA*, *MATE* and *BOMBILLA* where linked, the existing link was kept [1] and *AGUA CALIENTE* didn't get linked (of course, as it doesn't exist in `CUST_TERM`. 16. Run the tests: k$ prove t/db_dependent/Headin* => SUCCESS: Tests pass! 17. Sign off :-D [1] This really depends on how `LinkerKeepStale` is set, but what I describe is the default behavior. Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io>