Skip to content
Snippets Groups Projects
Commit e5939675 authored by Simon Hohl's avatar Simon Hohl Committed by Demian Katz
Browse files

Keep author fields even if no role is given (#1216)

parent 5bfeea38
No related merge requests found
......@@ -56,7 +56,10 @@ class BaseFormatter
$this->resetArrayIndices($value);
}
if ((is_array($value) && empty($value))
// We don't want to return empty values -- unless it's an empty array
// with a non-numeric key, since the key could be significant (e.g. in
// the case of an author name => roles array with no assigned roles).
if ((is_numeric($key) && is_array($value) && empty($value))
|| (is_bool($value) && !$value)
|| $value === null || $value === ''
) {
......
......@@ -68,6 +68,7 @@ class RecordFormatterTest extends \VuFindTest\Unit\TestCase
'subjectsExtended' => [
'vufind.method' => 'Formatter::getExtendedSubjectHeadings'
],
'authors' => ['vufind.method' => 'getDeduplicatedAuthors'],
];
}
......@@ -121,6 +122,10 @@ class RecordFormatterTest extends \VuFindTest\Unit\TestCase
'spelling' => 's',
'Building' => ['foo', new TranslatableString('bar', 'xyzzy')],
'AllSubjectHeadings' => [['heading' => 'subject']],
'DeduplicatedAuthors' => [
'primary' => ['Ms. A' => ['role' => ['Editor']]],
'secondary' => ['Mr. B' => [], 'Mr. C' => []],
],
]
);
return $driver;
......@@ -158,6 +163,10 @@ class RecordFormatterTest extends \VuFindTest\Unit\TestCase
'buildings' => ['foo', ['value' => 'bar', 'translated' => 'xyzzy']],
'recordPage' => 'http://record',
'subjectsExtended' => [['heading' => 'subject']],
'authors' => [
'primary' => ['Ms. A' => ['role' => ['Editor']]],
'secondary' => ['Mr. B' => [], 'Mr. C' => []],
],
],
];
$this->assertEquals($expected, $results);
......@@ -197,6 +206,7 @@ class RecordFormatterTest extends \VuFindTest\Unit\TestCase
'buildings' => [],
'recordPage' => [],
'subjectsExtended' => [],
'authors' => [],
];
$this->assertEquals($expected, $results);
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment