From 3ea2fc7da6bea20dc534eb93d96e74190e60f13e Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Thu, 20 Mar 2014 15:16:21 -0400 Subject: [PATCH] Simplified logic since we don't need to deal with non-arrays. --- module/VuFind/src/VuFind/ILS/Driver/MultiBackend.php | 12 +++++------- .../src/VuFindTest/ILS/Driver/MultiBackendTest.php | 6 ------ 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/module/VuFind/src/VuFind/ILS/Driver/MultiBackend.php b/module/VuFind/src/VuFind/ILS/Driver/MultiBackend.php index 64f4aa68b4e..4a7eff60e7b 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/MultiBackend.php +++ b/module/VuFind/src/VuFind/ILS/Driver/MultiBackend.php @@ -392,15 +392,13 @@ class MultiBackend extends AbstractBase protected function addIdPrefixes($data, $source, $modifyFields = array('id', 'cat_username') ) { - - if (!isset($data) || empty($data) ) { + if (!isset($data) || empty($data) || !is_array($data)) { return $data; } - $array = is_array($data) ? $data : array($data); - foreach ($array as $key => $value) { + foreach ($data as $key => $value) { if (is_array($value)) { - $array[$key] = $this->addIdPrefixes( + $data[$key] = $this->addIdPrefixes( $value, $source, $modifyFields ); } else { @@ -408,11 +406,11 @@ class MultiBackend extends AbstractBase && $value !== '' && in_array($key, $modifyFields) ) { - $array[$key] = $source . '.' . $value; + $data[$key] = $source . '.' . $value; } } } - return is_array($data) ? $array : $array[0]; + return $data; } /** diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/MultiBackendTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/MultiBackendTest.php index 15028d396e2..4bbdf2981af 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/MultiBackendTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/MultiBackendTest.php @@ -681,12 +681,6 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase $result = $this->callMethod($driver, 'addIdPrefixes', array($data, $source)); $this->assertEquals($data, $result); - /* test disabled 3/19/2014 -- do we really want to prefix non-array strings? - $data = "record"; - $result = $this->callMethod($driver, 'addIdPrefixes', array($data, $source)); - $this->assertEquals("$source.$data", $result); - */ - $data = array( "id" => "record1", "cat_username" => "record2" -- GitLab