Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem
When you add a field that has no database column, like a Bulk Operation field, to a Combined field filter in Views, an exception is thrown.
For example, in the User admin View, modify the combined field filter to include the Bulk operation field, then search.
Proposed resolution
Since no sure way is available to determine which field will and won't work with this filter until something like #2349465: Add an isComputed method to field handlers becomes available, use clickSortable to at least filter away most (maybe even all) undesirables.
Remaining tasks
Comment | File | Size | Author |
---|---|---|---|
#20 | 2401953-20.patch | 9.73 KB | Lendude |
#18 | 2401953-18.patch | 9.68 KB | Lendude |
#18 | interdiff-2401953-16-18.txt | 1.08 KB | Lendude |
#16 | 2401953-16.patch | 9.38 KB | Lendude |
#16 | interdiff-2401953-9-16.txt | 10.25 KB | Lendude |
Comments
Comment #2
LendudeAnd this should fix it.
this also removed the double check in the same setting
Comment #3
dawehnerAH! Good catch!
Don't we still need the
!empty()
check? Its better to be safe, you never knowComment #4
LendudeSince the default alias is 'unknown' (no idea why this isn't just FALSE or NULL, but it isn't), something would have to set this to something empty for this to occur, so don't know if that is something that would happen, but you are right, easy enough to still check, just in case.
Updated to patch to include the empty check.
Comment #5
dawehnerNot sure honestly, but let's not try to change this, as this could have all kind of related changes.
Comment #6
LendudeNow that I think about it....the problem that was raised by @alexpott with https://www.drupal.org/node/2370251 also might be an issue here.
With this fix, we silently skip over any fields in the filter config we don't like, with no warning to the end user that the config options are invalid/not used. So, I theory, the user could expect the view to be filtered by a certain value, but in fact it's not.
So do we need some kind of feedback on this? Or invalidate the View at some point?
I had a look at limiting the options array to fields with a field_alias, but aliases have not been set yet when buildOptionsForm() is called, so all aliases are 'unknown' at that point. So that's not something that can be used.
Any thoughts on this?
Comment #7
alexpottSo how come a user can add such a field to a combined filter - surely the correct fix is to not list the fields that can not be filtered on.
Comment #8
Lendude@alexpott I completely agree, but...
I had a chat with @dawehner on IRC about this as well and the problem is that it's impossible to detect which field will and which fields won't work at the time of building the options form. Like I said in #6, the criterium now used during query building can't be used because all aliases are 'unknown' at that time.
@dawehner said that when this feature was introduced it was accepted that it wouldn't work for some fields, the description for the field selector also says 'This filter doesn't work for very special field handlers.'
So to me it's now more about making sure that 'very special field handlers' are detected before exceptions are thrown. But unless we make every handler set a 'compatible with combine field filter' flag, I don't really see a criterium to test for during option building that would not give false positives or false negatives. If somebody else knows one, great!
But short of that, this is more about making sure people don't wind up facing an exception when we could have given them something more elegant.
Comment #9
LendudeMaybe abuse a different setting to test for a 'very special field handler'? If you can't click sort, you are probably dealing with something special right?
Not pretty, but gets the job done...
Comment #10
alexpottHow do we determine what to list on list of fields that can be a used as a normal filter? Also we need tests.
Comment #11
Lendude@alexpott, sorry not quite sure what you mean by 'How do we determine what to list on list of fields that can be a used as a normal filter?'
Comment #12
dawehnerWe could leverage the information from #2349465: Add an isComputed method to field handlers if that would land.
Comment #13
Lendude@dawehner That sounds perfect! Maybe postpone this waiting for that to land? No idea what the odds are of that making it in though.
Comment #14
LendudeComment #16
LendudeRerolled and updated the patch a bit.
Since #2349465: Add an isComputed method to field handlers is an API change, that won't get into 8.0.x, so the 'misuse' of clickSortable, makes sense for 8.0.x I feel. Maybe add a follow up to update it to isComputed when that becomes available.
Edit: Some extra stuff got into the interdiff, ignore the error display stuff.
Comment #17
dawehnerWe should try to explain why its not usable ...
Comment #18
LendudeAdded a comment with a @todo to the isComputed issue to indicate that this is a temp fix until there is something better to check.
Also made the error a bit more verbose.
Comment #20
LendudeDuh, updated the message but not the test.....
Comment #21
LendudeComment #22
dawehnerThank you!
Comment #23
alexpottGiven that doing this throws a Database exception I think that doing this fix in 8.0.x makes sense and we should update the patch on #2349465: Add an isComputed method to field handlers to change the use of clickSortable() to isComputed().
Committed af13634 and pushed to 8.0.x and 8.1.x. Thanks!