From 32d5c26e63d3ffb681b301a5d97ec7fd87d0ebe6 Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Fri, 16 Mar 2018 08:46:59 -0400
Subject: [PATCH] Fix bug: record data caching was not working.

---
 .../View/Helper/Root/RecordDataFormatter.php       |  2 +-
 .../View/Helper/Root/RecordDataFormatterTest.php   | 14 +++++++++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/module/VuFind/src/VuFind/View/Helper/Root/RecordDataFormatter.php b/module/VuFind/src/VuFind/View/Helper/Root/RecordDataFormatter.php
index 8c4d7895860..759096c7a62 100644
--- a/module/VuFind/src/VuFind/View/Helper/Root/RecordDataFormatter.php
+++ b/module/VuFind/src/VuFind/View/Helper/Root/RecordDataFormatter.php
@@ -178,7 +178,7 @@ class RecordDataFormatter extends AbstractHelper
             return $method;
         }
 
-        $useCache = isset($options['cacheData']) && $options['cacheData'];
+        $useCache = isset($options['useCache']) && $options['useCache'];
 
         if ($useCache) {
             $cacheKey = $driver->getUniqueID() . '|'
diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/RecordDataFormatterTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/RecordDataFormatterTest.php
index c2b02297491..23bdb096d76 100644
--- a/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/RecordDataFormatterTest.php
+++ b/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/RecordDataFormatterTest.php
@@ -92,8 +92,11 @@ class RecordDataFormatterTest extends \VuFindTest\Unit\ViewHelperTestCase
     protected function getDriver($overrides = [])
     {
         // "Mock out" tag functionality to avoid database access:
+        $methods = [
+            'getBuilding', 'getDeduplicatedAuthors', 'getContainerTitle', 'getTags'
+        ];
         $record = $this->getMockBuilder('VuFind\RecordDriver\SolrDefault')
-            ->setMethods(['getBuilding', 'getContainerTitle', 'getTags'])
+            ->setMethods($methods)
             ->getMock();
         $record->expects($this->any())->method('getTags')
             ->will($this->returnValue([]));
@@ -103,6 +106,15 @@ class RecordDataFormatterTest extends \VuFindTest\Unit\ViewHelperTestCase
             ->will($this->returnValue(0));
         $record->expects($this->any())->method('getContainerTitle')
             ->will($this->returnValue('0'));
+        // Expect only one call to getDeduplicatedAuthors to confirm that caching
+        // works correctly (we need this data more than once, but should only pull
+        // it from the driver once).
+        $authors = [
+            'primary' => ['Vico, Giambattista, 1668-1744.' => []],
+            'secondary' => ['Pandolfi, Claudia.' => []],
+        ];
+        $record->expects($this->once())->method('getDeduplicatedAuthors')
+            ->will($this->returnValue($authors));
 
         // Load record data from fixture file:
         $fixture = json_decode(
-- 
GitLab