Problem/Motivation
From #1851086: Replace admin/people with a View.
We need to be able to have optional handlers, such and language fields etc., that can ship with a default view but aren't necessarily needed
At the moment this is considered a broken handler, as it can't be found if the module is not available. This means that (e.g.) the admin/people view displays a warning when the language module is not available.

Proposed resolution
This could be resolved by adding an $optional parameter for views_get_handler() that determines whether a handler is 'optional'. Calling code can then use this parameter. For example, DisplayPluginBase::getHandlers() can check if an 'optional' key is set in the handler configuration, and pass this to views_get_handler() when it's called. This allows us to ignore missing handlers when they are considered optional.
Remaining tasks
If it is acceptable to have an optional handler, we should not show broken handler messages, and maybe not even load a broken handler stub instance - A point that needs to be discussed.
Here are two initial patches, one just suppressing the debug message if an optional flag is found, and the other actually not returning a handler instance.
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | drupal-1966424-13.patch | 18.07 KB | dawehner |
| #13 | interdiff.txt | 2.26 KB | dawehner |
| #8 | drupal-1966424-8.patch | 17.5 KB | dawehner |
| #8 | interdiff.txt | 3.16 KB | dawehner |
| #6 | vdc-1966424-6.patch | 14.87 KB | tim.plunkett |
Comments
Comment #1
damiankloip commentedHere is a screen grab from before/after using the admin/people patch referenced in the summary.
Comment #1.0
damiankloip commentedIssue summary formatting.
Comment #1.1
xjmUpdated issue summary.
Comment #2
tim.plunkettNot using the broken handler results in an even more wonky UI. We should definitely go in the direction of the first patch.
However, we can go one step further in simplifying the DX for callers. The tests look a bit more awkward, but that's not who we're optimizing for.
Comment #3
dawehnerThere is no need to have this marked as not optional.
This should explain that optional is defaulted to FALSE.
Comment #4
damiankloip commentedYep, I think I like this approach. Not sure if it makes things more confusing to read, as the params are a bit more self documenting. It's better encapsulating the logic inside views_get_handler() though.
+1
Comment #6
tim.plunkettAddressed the comments in #3 (thanks) and fixed two calls to this in tests I missed.
Still needs dedicated tests.
Comment #7
dawehnerI will either write tests tomorrow morning or in the evening, if noone else stepped forward in the meantime.
Comment #8
dawehnerAdded some test coverage for that.
Comment #9
tim.plunkett@dawehner++
Could be protected, I guess. Doesn't really matter.
non-existant
Nice!
Weird indentation
Comment #10
damiankloip commentedNon-existent?
Comment #11
damiankloip commentedLooking good, but then I don't expect anything less.
I vote we fix the test method name too while we are touching this test? That name is mildy offensive :)
Is it worth us also just adding a quick test that an actual handler with
optional = TRUEdoesn't throw a debug. I know it won't but you never know what'll happen in the future.Comment #12
xjm#10 is correct.
Comment #13
dawehnerIsn't that what assertFalse() is doing? Added a test for explicit 'optional' => FALSE.
Comment #14
tim.plunkettThis is awesome! Yay team.
Comment #15
tim.plunkettThis blocks #1851086: Replace admin/people with a View, so it is also major
Comment #16
webchickThis actually looks like nice code clean-up, in addition to providing that capability.
Committed and pushed to 8.x. Thanks!
Comment #17
xjmProbably merits a change notice?
Comment #18
xjmComment #19
dawehnerSo should we expose this bit in the UI?
Comment #20
xjm@dawehner, maybe a followup to discuss the possibility of the UI would be good? My gut reaction is no, because it adds another whole layer of complexity to the view, but not sure.
Comment #21
dawehnerWell, there are already a lot of different levels of configuration the normal user would never need. Additional I don't think changing config files by hand is recommended at all?
Comment #21.0
dawehnerUpdated issue summary.
Comment #22
chris matthews commentedFor more information as to why this issue was moved to the Drupal core project, please see issue #3030347: Plan to clean process issue queue
Comment #23
chris matthews commentedMoving back to the contributed Views issue queue and closing as outdated per https://www.drupal.org/project/views/issues/3030347#comment-13023447