From 15c3148177fff81420085abcc483e055fe3138ff Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Thu, 19 Dec 2024 09:06:27 -0100 Subject: [PATCH] fix: Syndetics cover fails if record's UPC has a leading zero Caused by the checksums being wrong. Test plan: On adb, with ktd vanilla test data, we can use record '76' as that has a UPC with a leading zero: http://localhost:8083/Record/76 1) Add valid syndetics settings. 2) Access the record: http://localhost:8083/Record/76 3) Notice the image is not found, this is because this record's UPC is '021561601628', and processImageURL is not identifying the returned image as a "not found" because it doesn't match any of the checksums it's verifying. 4) Apply the patch. Repeat the test plan. You'll need to click "Staff View" -> "Reload Cover" on the record page to clear the cover cache and force the request again but now the image should be displaying correctly. This is because the leading zeroes fail check and the returned image is properly identified as a 'not found' image, so getGroupedWorkCover will then check again but without stripping the leading zeroes, and work then. Finally, I decided to test for the other sizes as well, and noticed all the checksums are wrong, not the just the medium. Possibly caused by a change of default 'not found' images on syndetics' end. To test this, visit the following locally: http://localhost:8083/bookcover.php?id=ils:76&size=small&upc=021561601628&reload=1 http://localhost:8083/bookcover.php?id=ils:76&size=medium&upc=021561601628&reload=1 http://localhost:8083/bookcover.php?id=ils:76&size=large&upc=021561601628&reload=1 None of these work before the fix. All work after the fix. --- code/web/sys/Covers/BookCoverProcessor.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/web/sys/Covers/BookCoverProcessor.php b/code/web/sys/Covers/BookCoverProcessor.php index 8f6574c8d1..c9a0715dee 100644 --- a/code/web/sys/Covers/BookCoverProcessor.php +++ b/code/web/sys/Covers/BookCoverProcessor.php @@ -748,13 +748,13 @@ function processImageURL($source, $url, $attemptRefetch = true) { $imageChecksum = md5($image); if ($imageChecksum == 'e89e0e364e83c0ecfba5da41007c9a2c') { return false; - } elseif ($imageChecksum == 'f017f94ed618a86d0fa7cecd7112ab7e') { + } elseif ($imageChecksum == '798f904eabf783405079eaf699414801') { //Syndetics Unbound default image at medium size return false; - } elseif ($imageChecksum == 'dadde13fdb5f3775cdbdd25f34c0389b') { + } elseif ($imageChecksum == 'b13e33c0262a3a1f21dd20b826710cbc') { //Syndetics Unbound default image at small size return false; - } elseif ($imageChecksum == 'c6ddaf338cf667df0bf60045f05146db') { + } elseif ($imageChecksum == '821d0d442dbee0f51f4c803e8e9fc87a') { //Syndetics Unbound default image at large size return false; }