From: Dan Scott Date: Thu, 14 Jun 2018 17:59:42 +0000 (-0400) Subject: LP#1776954 Avoid empty string for tcn_source X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=ab56e0b3d6760c00701003a1cddcbe23a672a3fb;p=evergreen%2Fpines.git LP#1776954 Avoid empty string for tcn_source The tcn_source for some records is an empty string, instead of the database default of 'AUTOGEN', because the Perl record import code avoids a Perl warning in the logger info call by setting the value to an empty string if it can't find any other source (e.g. OCLC number). Unfortunately, the empty string then gets passed to the database, meaning that it satisfies the non-NULL constraint and does not invoke the default value of 'AUTOGEN'. The resulting MARCXML then contains an empty, self-closing 901 $b subfield () that causes an error for some other applications, such as Zotero, which do not anticipate empty subfields. The simple fix applied here is to follow the example for $source and $tcn of not setting the value of the tcn_source field in the bib record object if the corresponding variable evaluates to false (such as if it's an empty string). To test: create a basic record in the MARC editor that includes minimal fields (for example, a 100 and 245) so that it has no TCN source to extract. Check the MARCXML served up by SuperCat ("curl http:///opac/extras/supercat/retrieve/marcxml-uris/record/"). Before this patch, it will have a self-closing 901 $b subfield. After applying this patch and creating a new test record, the new test record will have a 901$b subfield with the value 'AUTOGEN'. A site that has been running without this patch for a long time might want to check how many bib records they have with an empty tcn_source: SELECT COUNT(*) FROM biblio.record_entry WHERE deleted IS FALSE AND tcn_source = ''; Sites can fix the problem by issuing UPDATE statements to set the 901$b to a value like 'AUTOGEN' or 'Unknown'. They should probably do it per-record, however, to avoid locking the table in a huge commit. Signed-off-by: Dan Scott Signed-off-by: Chris Sharp --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/BibCommon.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/BibCommon.pm index c461dba2ac..3f2cfbce60 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/BibCommon.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/BibCommon.pm @@ -107,7 +107,7 @@ sub biblio_record_xml_import { my $record = Fieldmapper::biblio::record_entry->new; $record->source(bib_source_from_name($source)) if $source; - $record->tcn_source($tcn_source); + $record->tcn_source($tcn_source) if $tcn_source; $record->tcn_value($tcn) if ($tcn); $record->creator($e->requestor->id); $record->editor($e->requestor->id);