LP#1749475 Protect against missing pubdate in biblio sort
authorDan Wells <dbw2@calvin.edu>
Thu, 21 Feb 2019 16:31:20 +0000 (11:31 -0500)
committerDan Wells <dbw2@calvin.edu>
Wed, 27 Feb 2019 19:13:23 +0000 (14:13 -0500)
The lack of date1 data in some records was causing this code to crash,
as an attempt was made to read textContent from nothingness.  Similar
to the publisher code right above, let's protect against such cases.

Signed-off-by: Dan Wells <dbw2@calvin.edu>
Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor.pm

index f011417..cb7d5b8 100644 (file)
@@ -449,8 +449,9 @@ $_TT_helpers = {
                 $$bib{item_type} = $xml->findnodes('//*[local-name()="attributes"]/*[local-name()="field"][@name="item_type"]')->get_node(1)->getAttribute('coded-value');
                 my $p = $xml->findnodes('//*[@tag="260" or @tag="264"]/*[@code="b"]')->get_node(1);
                 $$bib{publisher} = $p ? $p->textContent : '';
-                $$bib{pubdatesort} = $$bib{pubdate} = $xml->findnodes('//*[local-name()="attributes"]/*[local-name()="field"][@name="date1"]')->get_node(1)->textContent;
-                $$bib{pubdatesort} = lc($$bib{pubdatesort});
+                my $pd = $xml->findnodes('//*[local-name()="attributes"]/*[local-name()="field"][@name="date1"]')->get_node(1);
+                $$bib{pubdate} = $pd ? $pd->textContent : '';
+                $$bib{pubdatesort} = lc($$bib{pubdate});
                 $$bib{isbn} = $xml->findnodes('//*[@tag="020"]/*[@code="a"]')->to_literal_delimited(', ');
                 $$bib{issn} = $xml->findnodes('//*[@tag="022"]/*[@code="a"]')->to_literal_delimited(', ');
                 $$bib{upc} = $xml->findnodes('//*[@tag="024"]/*[@code="a"]')->to_literal_delimited(', ');