diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/BrowZine/Backend.php b/module/VuFindSearch/src/VuFindSearch/Backend/BrowZine/Backend.php index dec4a9b1e9ec16c81bc0ce51462c13f0e583fe44..b290a37c105a60f18db620926a06fe4700d20ea2 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/BrowZine/Backend.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/BrowZine/Backend.php @@ -107,8 +107,10 @@ class Backend extends AbstractBackend $e ); } + // Use array_values and array_filter to strip any nulls out of the + // response (these are present sometimes due to an apparent API bug) $results = isset($response['data']) && is_array($response['data']) - ? $response['data'] : []; + ? array_values(array_filter($response['data'])) : []; $collection = $this->createRecordCollection( [ 'offset' => $offset, diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/BrowZine/Response/RecordCollectionFactoryTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/BrowZine/Response/RecordCollectionFactoryTest.php index ecf47f4bd2f13a7c79f0bb881eee755d7be643f6..17d2c81f0f30f9ded8dee46645f17d4136fbe931 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/BrowZine/Response/RecordCollectionFactoryTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/BrowZine/Response/RecordCollectionFactoryTest.php @@ -49,7 +49,7 @@ class RecordCollectionFactoryTest extends TestCase */ public function testFactory() { - $resp = ['data' => [[], [], []]]; + $resp = ['data' => [['id' => 1], ['id' => 2], ['id' => 3]]]; $fact = new RecordCollectionFactory(); $coll = $fact->factory($resp); $this->assertEquals(3, count($coll));