Skip to content
Snippets Groups Projects
Commit 61b2f2f7 authored by catch's avatar catch
Browse files

Issue #2913971 by jhedstrom, TrevorBradley, amateescu: Views regression: 8.4.x...

Issue #2913971 by jhedstrom, TrevorBradley, amateescu: Views regression: 8.4.x EntityField can't handle a null row value from a non-required relationship
parent d078c928
No related branches found
No related tags found
No related merge requests found
......@@ -331,6 +331,15 @@ public function testGroupByWithEmptyRelationships() {
// Fourth result has no reference from EntityTestMul hence the output for
// should be empty.
$this->assertEqual('', $view->getStyle()->getField(3, 'name_2'));
$fields = $view->field;
// Check getValue for reference with a value. The first 3 rows reference
// EntityTestMul, so have value 'name1'.
$this->assertEquals('name1', $fields['name_2']->getValue($view->result[0]));
$this->assertEquals('name1', $fields['name_2']->getValue($view->result[1]));
$this->assertEquals('name1', $fields['name_2']->getValue($view->result[2]));
// Ensure getValue works on empty references.
$this->assertNull($fields['name_2']->getValue($view->result[3]));
}
}
......@@ -1052,6 +1052,12 @@ protected function getTableMapping() {
*/
public function getValue(ResultRow $values, $field = NULL) {
$entity = $this->getEntity($values);
// Ensure the object is not NULL before attempting to translate it.
if ($entity === NULL) {
return NULL;
}
// Retrieve the translated object.
$translated_entity = $this->getEntityFieldRenderer()->getEntityTranslation($entity, $values);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment