Bug 40508 - Set maxlength in marc21_framework_DEFAULT.yml
Summary: Set maxlength in marc21_framework_DEFAULT.yml
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: Main
Hardware: All All
: P5 - low minor
Assignee: David Cook
QA Contact: Testopia
URL:
Keywords:
Depends on: 40497
Blocks:
  Show dependency treegraph
 
Reported: 2025-07-25 02:49 UTC by David Cook
Modified: 2025-08-04 23:41 UTC (History)
2 users (show)

See Also:
GIT URL:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
This explicitly sets the "Max length" (maxlength) for MARC21 subfields in the default framework. Most subfields are set by default to 9999, except as follows: - 000 (Leader - fixed length control field): 24 - existing value - 008 (Fixed-length data elements--general information - fixed length control field)): 40 - existing value - 952$2 (Source of classification or shelving scheme): 10 - 952$8 (Collection): 80 - 952$a (Home library): 10 - 952$b (Current library): 10 - 952$c (Shelving location): 80 - 952$f (Coded location qualifier): 10 - 952$i (Inventory number): 80 - 952$o (Full call number): 255 - 952$p (Barcode): 20 - the limit on the barcode field - 952$t (Copy number): 32 - 952$y (Koha item type): 10 Note: This change only applies for new installations, existing installations will need to manually change their frameworks.
Version(s) released in:
Circulation function:


Attachments
Bug 40508: Add maxlength to marc21_framework_DEFAULT.yml (1001.88 KB, patch)
2025-07-25 02:55 UTC, David Cook
Details | Diff | Splinter Review
Bug 40508: Add maxlength to marc21_framework_DEFAULT.yml (1001.94 KB, patch)
2025-07-28 12:15 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 40508: (follow-up) Update more item field maxlengths (3.41 KB, patch)
2025-07-28 12:15 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 40508: Add maxlength to marc21_framework_DEFAULT.yml (1001.98 KB, patch)
2025-07-29 01:32 UTC, David Nind
Details | Diff | Splinter Review
Bug 40508: (follow-up) Update more item field maxlengths (3.46 KB, patch)
2025-07-29 01:32 UTC, David Nind
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description David Cook 2025-07-25 02:49:30 UTC
By explicitly setting maxlength in marc21_framework_DEFAULT.yml, we can change the default maxlength for fields in the default framework (and to a degree the ACQ framework).

See Bug 40471
Comment 1 David Cook 2025-07-25 02:50:56 UTC
The following patch uses the default 9999 for all fields except for the 000, 008, and 952$p.

000 and 008 use 24 and 40 respectively (which is set by the "sql_statements" at the bottom of the YAML file anyway.

We set 952$p to 20 as that's the limit on the barcode field (as per bug 40471).
Comment 2 David Cook 2025-07-25 02:55:48 UTC
Created attachment 184610 [details] [review]
Bug 40508: Add maxlength to marc21_framework_DEFAULT.yml

This patch adds maxlength to marc21_framework_DEFAULT.yml.
It uses the default of 9999 for most subfields except 000, 008,
and 952$p. The 000 and 008 use 24 and 40 respectively, although
this is already enforced by the sql_statements at the end of the
file.

The 952$p is set to 20, since the barcode DB field has a length of 20.

Test plan:
0. Apply the patch
1. Take down KTD
2. Bring up KTD
3. Look at the 000, 008, and 952 fields in the default framework
4. Note that 000 uses maxlength 24, 008 uses maxlength 40, 952$p uses
maxlength 20, and every other subfield uses 9999
Comment 3 Owen Leonard 2025-07-28 12:15:29 UTC
Created attachment 184743 [details] [review]
Bug 40508: Add maxlength to marc21_framework_DEFAULT.yml

This patch adds maxlength to marc21_framework_DEFAULT.yml.
It uses the default of 9999 for most subfields except 000, 008,
and 952$p. The 000 and 008 use 24 and 40 respectively, although
this is already enforced by the sql_statements at the end of the
file.

The 952$p is set to 20, since the barcode DB field has a length of 20.

Test plan:
0. Apply the patch
1. Take down KTD
2. Bring up KTD
3. Look at the 000, 008, and 952 fields in the default framework
4. Note that 000 uses maxlength 24, 008 uses maxlength 40, 952$p uses
   maxlength 20, and every other subfield uses 9999

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 4 Owen Leonard 2025-07-28 12:15:31 UTC
Created attachment 184744 [details] [review]
Bug 40508: (follow-up) Update more item field maxlengths

- 2 - Source of classification or shelving scheme
- 8 - Collection
- a - Home library
- b - Current library
- c - Shelving location
- f - Coded location qualifier
- i - Inventory number
- o - Full call number
- t - Copy number
- y - Koha item type
Comment 5 David Nind 2025-07-29 01:32:21 UTC
Created attachment 184763 [details] [review]
Bug 40508: Add maxlength to marc21_framework_DEFAULT.yml

This patch adds maxlength to marc21_framework_DEFAULT.yml.
It uses the default of 9999 for most subfields except 000, 008,
and 952$p. The 000 and 008 use 24 and 40 respectively, although
this is already enforced by the sql_statements at the end of the
file.

The 952$p is set to 20, since the barcode DB field has a length of 20.

Test plan:
0. Apply the patch
1. Take down KTD
2. Bring up KTD
3. Look at the 000, 008, and 952 fields in the default framework
4. Note that 000 uses maxlength 24, 008 uses maxlength 40, 952$p uses
   maxlength 20, and every other subfield uses 9999

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: David Nind <david@davidnind.com>
Comment 6 David Nind 2025-07-29 01:32:24 UTC
Created attachment 184764 [details] [review]
Bug 40508: (follow-up) Update more item field maxlengths

- 2 - Source of classification or shelving scheme
- 8 - Collection
- a - Home library
- b - Current library
- c - Shelving location
- f - Coded location qualifier
- i - Inventory number
- o - Full call number
- t - Copy number
- y - Koha item type

Signed-off-by: David Nind <david@davidnind.com>
Comment 7 Marcel de Rooy 2025-08-01 07:36:13 UTC
Please see also bug 40284. For fields 005, 006 and 007. We are touching the same file.
Setting the length to 9999 is definitely wrong.
Comment 8 Owen Leonard 2025-08-01 11:24:18 UTC
(In reply to Marcel de Rooy from comment #7)

> Setting the length to 9999 is definitely wrong.

9999 is the default found in the code, for example:

authorities.pl line 104:

# determine maximum length; 9999 bytes per ISO 2709 except for leader and MARC21 008
my $max_length = 9999;
Comment 9 David Cook 2025-08-03 23:19:18 UTC
(In reply to Owen Leonard from comment #8)
> (In reply to Marcel de Rooy from comment #7)
> 
> > Setting the length to 9999 is definitely wrong.
> 
> 9999 is the default found in the code, for example:
> 
> authorities.pl line 104:
> 
> # determine maximum length; 9999 bytes per ISO 2709 except for leader and
> MARC21 008
> my $max_length = 9999;

Changing this one back to "Signed Off", because bug 40284 and bug 40508 are not mutually exclusive. 

We can add a follow-up here to make the marc21_framework_DEFAULT.yml change from bug 40284 unnecessary, or we can just include them both. It doesn't really matter. 

If both are pushed, then the right thing will happen in the end.
Comment 10 Marcel de Rooy 2025-08-04 06:47:57 UTC
For clarity, a length of 9999 for field 005-007 is definitely wrong. See LOC.
Comment 11 David Cook 2025-08-04 23:41:41 UTC
(In reply to Marcel de Rooy from comment #10)
> For clarity, a length of 9999 for field 005-007 is definitely wrong. See LOC.

No one is arguing with you about that.

What Owen is saying is that Koha's default for those fields is already 9999. The patch - for the most part - is just reflecting the status quo. Happy for you to add follow-ups like Owen did for the item fields.