]> git.evergreen-ils.org Git - Evergreen.git/commit
LP#1776954 Avoid empty string for tcn_source
authorDan Scott <dscott@laurentian.ca>
Thu, 14 Jun 2018 17:59:42 +0000 (13:59 -0400)
committerChris Sharp <csharp@georgialibraries.org>
Thu, 24 Sep 2020 17:13:44 +0000 (13:13 -0400)
commit0cd36dc4addbce44be1b90a026ae7ecdd9dd27f7
treedad8efe6c061c3e054856036b60b0eb9b0771720
parentc696b86c9bb5ff60e19e7f6e74017daf24c5a802
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
(<subfield code="b"/>) 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://<hostname>/opac/extras/supercat/retrieve/marcxml-uris/record/<bib-id>").
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 <dscott@laurentian.ca>
Signed-off-by: Chris Sharp <csharp@georgialibraries.org>
Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/BibCommon.pm