From 7fc7d5a16ed4e3ae2c7d5a5ba2bd1425f0282361 Mon Sep 17 00:00:00 2001 From: Josh Stompro Date: Sat, 27 Feb 2016 08:54:04 -0600 Subject: [PATCH] LP#1549393 - Remove undef values from isbn and issn arrays. This prevents empty requests being sent to content providers. This caused a problem for us because invalid ISBNs were causing requests to Content Cafe to fail, since Content Cafe returns an error if there is a blank key sent along with valid ISBNs and UPCs. Specifically we had problems with DVD records from Baker & Taylor because B&T creates unoffical ISBNs for the DVDs they sell. Those ISBN's do not validate when run through B::ISBN. ISSNs are also cleaned since they are validated and set to undef if invalid just like ISBNs are. It shouldn't hurt to not send blank requests to providers in any case. To test: 1. I know this is a problem with Content Cafe, I don't know if any other providers are effected. Let me know if you need Content Cafe credentials to test. 2. Add an invalid ISBN 020a entry to a bib record that has added content. 9786316271976 is an example of a fake ISBN that doesn't pass B::ISBN validation. Or just make up a fake number. 3. Clear out the memcache entries for that record. In 2.9+ there is a link to clear the cache in the record detail view under Permalink. 4. Reload the record and the cover art and other added content should not be displayed. This is because the invalid ISBN gets set to undef , and the undef gets sent to content cafe as a blank key request. 5. Now apply the fix. Clear the memcache entries for that bib, and now the cover art should be displayed since the undef entries due to the invalid ISBN's have been removed. Signed-off-by: Josh Stompro Signed-off-by: Galen Charlton --- Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent.pm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent.pm index a1f1767216..254d790cf6 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent.pm @@ -181,6 +181,11 @@ sub handler { undef $_ if !defined($_->{value}); } @issns; + #Remove undef values from @isbns and @issns. + #Prevents empty requests to providers + @isbns = grep {defined} @isbns; + @issns = grep {defined} @issns; + $keyhash = { isbn => [map {$_->{value}} @isbns], issn => [map {$_->{value}} @issns], -- 2.11.0