Bug 42039

Summary: Properly set LDR/5 for deleted bibliographic records
Product: Koha Reporter: Janusz Kaczmarek <januszop>
Component: MARC Bibliographic data supportAssignee: Janusz Kaczmarek <januszop>
Status: Signed Off --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: dcook, m.de.rooy
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42044
GIT URL: Initiative type: ---
Sponsorship status: Sponsored Comma delimited list of Sponsors: Pontificia Università di San Tommaso d'Aquino (Angelicum)
Crowdfunding goal: 0 Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Bug 42039: Properly set LDR/5 for deleted bibliographic records
Bug 42039: Unit tests
Bug 42039: Properly set LDR/5 for deleted bibliographic records
Bug 42039: Unit tests

Description Janusz Kaczmarek 2026-03-09 16:31:11 UTC
For deleted authority records we automatically set LDR/5 to 'd' (cf. https://www.loc.gov/marc/authority/adleader.html). The same should be done for bibliographic records:

"System-Generated Elements - Following Leader elements are usually system generated:
[...]
05 	Record status"
(cf. https://www.loc.gov/marc/bibliographic/bdleader.html)
Comment 1 Janusz Kaczmarek 2026-03-09 17:20:54 UTC
Created attachment 195017 [details] [review]
Bug 42039: Properly set LDR/5 for deleted bibliographic records

For deleted authority records we automatically set LDR/5 to 'd'
(cf. https://www.loc.gov/marc/authority/adleader.html).

Test plan:
==========
1. Find any bibliographic record. Check the value of the 5th byte of
   the leader. It should not be equal to 'd'.
2. Delete the bibliographic record (you may have to delete the items
   first).
3. In ktd --dbshell check the 5th byte of the leader, e.g.:
   select biblionumber, ExtractValue(metadata, '//leader') from deletedbiblio_metadata order by timestamp desc limit 1;
   It should be equlal to the initial value.
4. Apply the patch ; restart_all.
5. Repeat p. 1-3. The 5th byte of the leader should now be properly
   set to 'd'.

Sponsored-by: Pontificia Università di San Tommaso d'Aquino (Angelicum)
Comment 2 Janusz Kaczmarek 2026-03-09 17:20:56 UTC
Created attachment 195018 [details] [review]
Bug 42039: Unit tests
Comment 3 Roman Dolny 2026-03-09 18:39:18 UTC
Created attachment 195022 [details] [review]
Bug 42039: Properly set LDR/5 for deleted bibliographic records

For deleted authority records we automatically set LDR/5 to 'd'
(cf. https://www.loc.gov/marc/authority/adleader.html).

Test plan:
==========
1. Find any bibliographic record. Check the value of the 5th byte of
   the leader. It should not be equal to 'd'.
2. Delete the bibliographic record (you may have to delete the items
   first).
3. In ktd --dbshell check the 5th byte of the leader, e.g.:
   select biblionumber, ExtractValue(metadata, '//leader') from deletedbiblio_metadata order by timestamp desc limit 1;
   It should be equlal to the initial value.
4. Apply the patch ; restart_all.
5. Repeat p. 1-3. The 5th byte of the leader should now be properly
   set to 'd'.

Sponsored-by: Pontificia Università di San Tommaso d'Aquino (Angelicum)
Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
Comment 4 Roman Dolny 2026-03-09 18:39:20 UTC
Created attachment 195023 [details] [review]
Bug 42039: Unit tests

Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>