https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20551
--- Comment #119 from David Gustafsson <[email protected]> --- (In reply to Arthur Suzuki from comment #114) > Also I had some errors in the record_iterator sub. > Fixed by explicitely using $deleted_record_id instead of $_ : > > my $records_iterator = sub { > if (my $record_id = pop(@record_ids)) { > return _get_record_for_export( { %{$params}, record_id => > $record_id } ); > } > elsif (my $deleted_record_id = pop(@deleted_record_ids)) { > return _get_record_for_export( > { > %{$params}, > record_type => 'deleted_bibs', > - record_id => $_, > + record_id => $deleted_record_id, > resultset => $deleted_resultset > } > ); > } > return; > }; > > I guess the previous error was due to no biblionumber being passed to the > _get_record_for_export sub. I don't think that could occur as the deleted biblionumber is always retrieved from the database before and thus always exists. But I agree it should be added to be consistent with (In reply to Arthur Suzuki from comment #113) > Hello, > In some condition the code could fail : > in the sub _get_deleted_biblio_for_export : > ---- > # Creating schema is expensive, allow caller to > > # pass it so don't have to recreate for each call > > my $resultset = $params->{resultset} || > Koha::Database->new()->schema()->resultset('DeletedbiblioMetadata'); > my $marc_flavour = C4::Context->preference('marcflavour'); > my $biblio_metadata = $resultset->find( > { > 'biblionumber' => $biblionumber, > 'format' => 'marcxml', > 'schema' => $marc_flavour > } > ); > my $marc_xml = $biblio_metadata->metadata; > $marc_xml = StripNonXmlChars($marc_xml); > ---- > > It seems that an empty result set could lead to querying an empty > $biblio_metadata object, resulting in a crash. > Probably should warn about "no deleted records" and early return in case of > empty resultset? I don't think that could occur as the deleted biblionumber is always retrieved from the database before and thus always exists. But I agree it should be added to be consistent with _get_biblio_for_export and future proofing the code. You are right it was triggered by me forgetting to replace $_ with $deleted_record_id in the previous patch. I have fixed this now. Also changed the table deleted biblios is selected from in export_records.pl from deletedbiblio to deletedbiblio_metadata as biblio_metadata is used for non deleted biblios. The deleted biblios resultset is now also cached instead of passed as an argument. -- You are receiving this mail because: You are watching all bug changes. _______________________________________________ Koha-bugs mailing list [email protected] https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
