Bug 32800: Don't embed items for deleted records

To test:
1 - Delete a biblio
2 - perl /kohadevbox/koha/misc/migration_tools/build_oai_sets.pl -v -i -r
3 - Error:
    Can't call method "items" on an undefined value at /kohadevbox/koha/Koha/Biblio/Metadata.pm line 163.
4 - Apply patch
5 - Repeat
6 - Success!

Signed-off-by: Magnus Enger <magnus@libriotech.no>
Works as advertised.
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Nick Clemens 2023-02-02 15:58:10 +00:00 committed by Tomas Cohen Arazi
parent 3143549403
commit 37bf88d252
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F

View file

@ -79,12 +79,12 @@ my $mappings = GetOAISetsMappings;
# Get all biblionumbers and marcxml # Get all biblionumbers and marcxml
print "Retrieving biblios... " if $verbose; print "Retrieving biblios... " if $verbose;
my $query = qq{ my $query = qq{
SELECT biblionumber, metadata SELECT biblionumber, metadata, 0 as "deleted"
FROM biblio_metadata FROM biblio_metadata
WHERE format='marcxml' WHERE format='marcxml'
AND `schema` = ? AND `schema` = ?
UNION UNION
SELECT biblionumber, metadata SELECT biblionumber, metadata, 1 as "deleted"
FROM deletedbiblio_metadata FROM deletedbiblio_metadata
WHERE format='marcxml' WHERE format='marcxml'
AND `schema` = ? AND `schema` = ?
@ -140,7 +140,7 @@ foreach my $res (@$results) {
warn "(biblio $biblionumber) Error while creating record from marcxml: $@"; warn "(biblio $biblionumber) Error while creating record from marcxml: $@";
next; next;
} }
if($embed_items) { if( $embed_items && !($res->{'deleted'}) ) {
$record = Koha::Biblio::Metadata->record( $record = Koha::Biblio::Metadata->record(
{ {
record => $record, record => $record,