Issue #3180227 by danflanagan8, robertom, xjm, Lendude, quietone: Notice: Trying to access array offset on value of type null in Drupal\views\Plugin\views\display\EntityReference->query()
parent
aaf6426b64
commit
0f6101a7cb
core/modules/views
src/Plugin/views/display
tests/src/Functional/Plugin
|
@ -160,7 +160,18 @@ class EntityReference extends DisplayPluginBase {
|
|||
$id_table = $this->view->storage->get('base_table');
|
||||
$this->id_field_alias = $this->view->query->addField($id_table, $id_field);
|
||||
|
||||
$options = $this->getOption('entity_reference_options');
|
||||
$options = $this->getOption('entity_reference_options') ?? [];
|
||||
// The entity_reference_options are typically set during a call to
|
||||
// Drupal\views\Plugin\EntityReferenceSelection\ViewsSelection::initializeView().
|
||||
// If any entity_reference_options are not yet set, we apply the same
|
||||
// default values that would typically be added by that method.
|
||||
$default_options = [
|
||||
'match' => NULL,
|
||||
'match_operator' => 'CONTAINS',
|
||||
'limit' => 0,
|
||||
'ids' => NULL,
|
||||
];
|
||||
$options += $default_options;
|
||||
|
||||
// Restrict the autocomplete options based on what's been typed already.
|
||||
if (isset($options['match'])) {
|
||||
|
|
|
@ -275,6 +275,23 @@ class DisplayEntityReferenceTest extends ViewTestBase {
|
|||
$view->setDisplay('entity_reference_1');
|
||||
$render = $view->display_handler->render();
|
||||
$this->assertSame([], $render, 'Render returned empty array');
|
||||
|
||||
// Execute the View without setting the 'entity_reference_options'.
|
||||
// This is equivalent to using the following as entity_reference_options.
|
||||
// @code
|
||||
// $options = [
|
||||
// 'match' => NULL,
|
||||
// 'match_operator' => 'CONTAINS',
|
||||
// 'limit' => 0,
|
||||
// 'ids' => NULL,
|
||||
// ];
|
||||
// @endcode
|
||||
// Assert that this view returns a row for each test entity.
|
||||
$view->destroy();
|
||||
$view = Views::getView('test_display_entity_reference');
|
||||
$view->setDisplay('entity_reference_1');
|
||||
$this->executeView($view);
|
||||
$this->assertCount(13, $view->result, 'Search returned thirteen rows');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue