This error occurs when an exposed sort has been added to a view, and an exposed filter is subsequently added. When the filter identifier is validated, Drupal\views\Plugin\views\display\DisplayPluginBase->isIdentifierUnique() runs through all handlers and the line
$id != $key && $identifier == $handler->options['expose']['identifier']
throws the notice since exposed sorts don't have this option.
This seemed to be an issue in D7 views as well (see #1456836: AJAX HTTP error: Undefined index: identifier in is_identifier_unique()).
A straight forward fix would be to check if that option is set but there's probably a nicer solution, potentially only iterating over handlers that have the identifier option in the first place?
Comments
Comment #2
acbramley commentedHere's the failing test.
Comment #3
acbramley commentedThis time in the correct location and namespace...
Comment #5
lendude@acbramley++
Nice to see test coverage for this!
The following feedback is all 'perfect world' type feedback and is not to take anything away from this test:
It depends on the node module, would be nice to have it use EntityTest instead.
Depends on the default content View, there is a test version of that so that would be better, but this should be testable with any View, even just views.view.test_view.yml
Comment #6
acbramley commented@Lendude thanks for the review! All very valid points, working on the Kernel test now.
Comment #7
acbramley commentedReworked as a Kernel test, I tried also adding:
But I must be failing to understand what the function is used for as it was returning TRUE.
Comment #9
robloachYour workaround solution was something like this?
Comment #10
lendude@acbramley that assertFalse was failing because the filter was using the Broken handler.
Bit of a reroll to not use a dedicated View for this. We can easily add the needed settings in the test, and i think that makes it much clearer what we are testing here.
And I think the fix in #9 is fine.
Comment #11
lendudeBleh and now with the fix as well.....
Comment #16
otrolopezmasIn drupal 8.5.3 this is still happening. I re-ran the test for the patch and they pass for d8.5 with php 5.6 and php 7.
What can we do to progress with the implementation of this solution?
Comment #18
Anonymous (not verified) commentedPatch 2882031-10.patch works like a charm on 8.6.4.
Thank you very much.
Comment #19
theodorosploumisPatch from #comment-12151207 works with Drupal 8.7.1. Thanks.
Comment #20
anoopjohn commentedI can confirm that this patch works on 8.7.10 and 8.8.x dev
Comment #21
anoopjohn commentedComment #22
lendude@anoopjohn thanks for looking into this one. Re-queued the tests against a somewhat more recent version of core :)
Comment #23
alexpottAdding issue credit.
Comment #24
alexpottCommitted and pushed 258c4eac9c to 9.0.x and 4452522144 to 8.9.x. Thanks!
Will ask other committers about back porting to 8.8.x
Comment #27
alexpott@catch +1'd the backport.