Commit 258c4eac authored by alexpott's avatar alexpott

Issue #2882031 by Lendude, acbramley, RobLoach: Undefined index: identifier in...

Issue #2882031 by Lendude, acbramley, RobLoach: Undefined index: identifier in view's DisplayPluginBase->isIdentifierUnique()
parent 92e8b7b6
......@@ -2547,7 +2547,7 @@ public function isIdentifierUnique($id, $identifier) {
}
}
else {
if ($id != $key && $identifier == $handler->options['expose']['identifier']) {
if ($id != $key && isset($handler->options['expose']['identifier']) && $identifier == $handler->options['expose']['identifier']) {
return FALSE;
}
}
......
......@@ -56,7 +56,7 @@ class DisplayKernelTest extends ViewsKernelTestBase {
*
* @var array
*/
public static $testViews = ['test_display_defaults'];
public static $testViews = ['test_display_defaults', 'test_view'];
/**
* Tests the default display options.
......@@ -115,4 +115,51 @@ public function testGetPlugin() {
$this->assertIdentical($first, $second, 'The same plugin instance was returned.');
}
/**
* Tests the ::isIdentifierUnique method.
*/
public function testisIdentifierUnique() {
$view = Views::getView('test_view');
$view->initDisplay();
// Add a handler that doesn't have an Identifier when exposed.
$sorts = [
'name' => [
'id' => 'name',
'field' => 'name',
'table' => 'views_test_data',
'plugin_id' => 'standard',
'order' => 'asc',
'expose' => ['label' => 'id'],
'exposed' => TRUE,
],
];
// Add a handler that does have an Identifier when exposed.
$filters = [
'id' => [
'field' => 'id',
'id' => 'id',
'table' => 'views_test_data',
'value' => [],
'plugin_id' => 'numeric',
'exposed' => TRUE,
'expose' => [
'operator_id' => '',
'label' => 'Id',
'description' => '',
'identifier' => 'id',
'required' => FALSE,
'remember' => FALSE,
'multiple' => FALSE,
],
],
];
$view->display_handler->setOption('sorts', $sorts);
$view->display_handler->setOption('filters', $filters);
$view->save();
$this->assertTrue($view->display_handler->isIdentifierUnique('some_id', 'some_id'));
$this->assertFalse($view->display_handler->isIdentifierUnique('some_id', 'id'));
}
}
Markdown is supported
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