From fc45a418407998778cd46737dffd5967137f45cb Mon Sep 17 00:00:00 2001 From: Janusz Kaczmarek Date: Mon, 9 Mar 2026 15:27:27 +0000 Subject: [PATCH] Bug 42039: Properly set LDR/5 for deleted bibliographic records MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- C4/Biblio.pm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 863f4d34b4..532e8c23a2 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -2863,6 +2863,17 @@ sub _koha_delete_biblio_metadata { my $schema = Koha::Database->new->schema; $schema->txn_do( sub { + my $metadata = Koha::Biblio::Metadatas->find( { biblionumber => $biblionumber } ); + if ($metadata) { + my $marc = $metadata->record; + if ($marc) { + my $leader = $marc->leader; + substr( $leader, 5, 1, 'd' ); + $marc->leader($leader); + my $encoding = C4::Context->preference("marcflavour"); + $metadata->update( { metadata => $marc->as_xml_record($encoding) } ); + } + } $dbh->do( q| INSERT INTO deletedbiblio_metadata (biblionumber, format, `schema`, metadata) -- 2.39.5