Bug 39545 - Construct more complete 773 content when creating a child record
Summary: Construct more complete 773 content when creating a child record
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: Cataloging (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low enhancement
Assignee: Janusz Kaczmarek
QA Contact: Martin Renvoize (ashimema)
URL:
Keywords:
Depends on: 37305
Blocks: 34482
  Show dependency treegraph
 
Reported: 2025-04-03 13:16 UTC by Janusz Kaczmarek
Modified: 2025-05-13 06:44 UTC (History)
3 users (show)

See Also:
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:


Attachments
Bug 39545: Better generation of 773 field for a child record (MARC21) (5.91 KB, patch)
2025-04-03 14:27 UTC, Janusz Kaczmarek
Details | Diff | Splinter Review
Bug 39545: Unit tests (4.18 KB, patch)
2025-04-03 14:27 UTC, Janusz Kaczmarek
Details | Diff | Splinter Review
Bug 39545: Better generation of 773 field for a child record (MARC21) (5.96 KB, patch)
2025-04-03 17:24 UTC, Roman Dolny
Details | Diff | Splinter Review
Bug 39545: Unit tests (4.23 KB, patch)
2025-04-03 17:24 UTC, Roman Dolny
Details | Diff | Splinter Review
Bug 39545: Unit tests (4.23 KB, patch)
2025-05-02 16:07 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 39545: (follow-up) Apply same logic to Koha::Biblio (8.91 KB, patch)
2025-05-02 16:07 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 39545: (follow-up) Apply same logic to Koha::Biblio (23.13 KB, patch)
2025-05-06 13:11 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 39545: Better generation of 773 field for a child record (MARC21) (2.00 KB, patch)
2025-05-06 15:56 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 39545: (follow-up) Apply same logic to Koha::Biblio (24.53 KB, patch)
2025-05-06 15:56 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Janusz Kaczmarek 2025-04-03 13:16:34 UTC
When creating a child record (New > New child record from Normal view) the information put in field 773 is very basic, sometimes not complete (e.g. only one ISBN, only 245 $a in 773 $t, 773 $w missing 003 of the host record etc.) and put in random order.
Comment 1 Janusz Kaczmarek 2025-04-03 14:27:38 UTC
Created attachment 180571 [details] [review]
Bug 39545: Better generation of 773 field for a child record (MARC21)

When creating a child record (New > New child record from Normal view)
the information put in field 773 is very basic, sometimes not
complete (e.g. only one ISBN, only 245 $a in 773 $t, 773 $w
missing 003 of the host record etc.) and put in random order.

Test plan:
==========
1. Find any record to be a host record for an analytical record. You
   can enrich the record with multiple 020, 490+830 fields, make sure that
   there are 001 and 003 fields present.
2. From upper menu chose New > New child record.
3. See the generated field 773 - the subfields are incomplete and in
   random order.
4. Apply the patch ; restart_all.
5. Repeat p. 2.-3. See that the generated 773 field contains now much
   more information, including 773 $7 and also preset leader.
Comment 2 Janusz Kaczmarek 2025-04-03 14:27:40 UTC Comment hidden (obsolete)
Comment 3 Roman Dolny 2025-04-03 17:24:36 UTC Comment hidden (obsolete)
Comment 4 Roman Dolny 2025-04-03 17:24:38 UTC Comment hidden (obsolete)
Comment 5 Martin Renvoize (ashimema) 2025-05-02 15:42:00 UTC
We have three functions for this.. I really want to merge them at some point, but I also don't want them to fall further out of sync in the meantime.

Can we also look at PrepMarcHost in the same file, and more importantly in my opinion the generate_marc_host_field method in Koha::Biblio?
Comment 6 Martin Renvoize (ashimema) 2025-05-02 16:07:05 UTC Comment hidden (obsolete)
Comment 7 Martin Renvoize (ashimema) 2025-05-02 16:07:08 UTC Comment hidden (obsolete)
Comment 8 Martin Renvoize (ashimema) 2025-05-02 16:09:35 UTC
A quick addition on a Friday.. I'll try to return to this and update tests.. I'd love to drop the C4 version and jus use the Koha one if we can manage it :)
Comment 9 Martin Renvoize (ashimema) 2025-05-06 09:41:23 UTC
Hmm.. you remove subfield s handling here.. coming from the 240$a. was this deliberate?
Comment 10 Martin Renvoize (ashimema) 2025-05-06 13:11:27 UTC Comment hidden (obsolete)
Comment 11 Martin Renvoize (ashimema) 2025-05-06 13:14:29 UTC
I need a cataloguer to weight in here I'm afraid.

I've used the operation of syncing this up in the Koha::Biblio method to do a deep dive back into it.

I've noted all the changes explicitly in my commit message, and I'm not entirely sure they're all correct.

For instance, I'm not really sure about the punctuation handling and I could see that possibly causing problems for others.

I'm also not sure about the removal of subfield s handling.. maybe that needs more consideration.

Finally.. I also found whilst updating unit tests, that the regular expression used for punctuation handling in the 245 work of the original patch doesn't catch trailing whitespace which doesn't feel entirely appropriate as in my findings 'as_string' adds such space.
Comment 12 Martin Renvoize (ashimema) 2025-05-06 14:10:10 UTC
OK.. I've remember where all this got to last time around now.. can we please rework this atop the other bugs in the queue already that heavily affect these area's..

I've put them into the dependencies but I've not rebased the changes here yet..
Comment 13 Martin Renvoize (ashimema) 2025-05-06 15:14:53 UTC
Rebasing this now, we can drop your patch entirely as the dependencies already removed that method. We can then use my patch that implements your changes against the more modern method. However, I think we're doing too much in one bug here still and we need a clear discussion around the changes
Comment 14 Martin Renvoize (ashimema) 2025-05-06 15:56:06 UTC
Created attachment 181987 [details] [review]
Bug 39545: Better generation of 773 field for a child record (MARC21)

When creating a child record (New > New child record from Normal view)
the information put in field 773 is very basic, sometimes not
complete (e.g. only one ISBN, only 245 $a in 773 $t, 773 $w
missing 003 of the host record etc.) and put in random order.

Test plan:
==========
1. Find any record to be a host record for an analytical record. You
   can enrich the record with multiple 020, 490+830 fields, make sure that
   there are 001 and 003 fields present.
2. From upper menu chose New > New child record.
3. See the generated field 773 - the subfields are incomplete and in
   random order.
4. Apply the patch ; restart_all.
5. Repeat p. 2.-3. See that the generated 773 field contains now much
   more information, including 773 $7 and also preset leader.

Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
Rebased-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
The rebase removed the majority of this patch as the prepare_host_field
method was removed entirely upstream.  The follow-up patch re-implements
the same but in the newer Koha::Biblio->generate_marc_host_field method
instead.  We also dropped the Unit tests that were introduced in the
subsequent patch.
Comment 15 Martin Renvoize (ashimema) 2025-05-06 15:56:10 UTC
Created attachment 181988 [details] [review]
Bug 39545: (follow-up) Apply same logic to Koha::Biblio

This patch updates the Koha::Biblio->generate_marc_host_field method to
more closely match the updated logic in C4::Biblio::prep_marc_host.

We change a number of things including:
 1) Constructinging the 773 subfield generation from a hash to an array
    to preserve field order.
 2) Updating main entry handling for 100/110/111 fields to clone the
    field and then remove relevant subfields as apposed to fetching only
    a limited set of subfields.
 3) Add handling to generate subfield 7 content depending on LDR and
    Main Entry information
 4) Improve handling for title subfield construction from 245 to respect
    non-filing characters and remove trailing punctuation
 5) Remove trailing punctuation from subfield b when generated from 250
 6) Remove generation of subfield s from the 240 field entirely
 7) Remove trailing punctuation from subfield d when generated from 260
 8) Add generation of subfield k from 800-830 fields

Rebased-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
We dropped the upstream aforementioned C4::Biblio method, but this patch
faithfully replicates it's functionality within
Koha::Biblio->generate_marc_host_field
Comment 16 Heather Hernandez 2025-05-09 16:38:29 UTC
Retired cataloger here!!

Looking at Comment 15 from Martin, all looks good with these caveats/comments:

I really must object to "Remove generation of subfield s from the 240 field entirely" because VAST quantities of records have an incredibly valuable 240 that absolutely must be included in the 773, including records for Bibles, books of the Bible, laws and statutes, and translations.  The preservation of this string in the 773 is essential, and frequently used--analytic records/child records are, indeed, created for these entities due to their being issued serially, for chapters/parts being used/assigned in academic settings, analytic/child records being cataloged for relevant treaties and/or conventions issued in compilations, etc.  Especially for legal materials, the $s and the $t should be included together--it's normal to include both, anyway.  These fields are incredibly important for academic libraries, specialized libraries, government libraries, law libraries, etc.

There should also be generation of subfield d from 264, since many catalogs have newer records with a 264 while also having older records with a 260.

Hope this helps!!
--h2