After a long talk with defr and bojanz in Paris, I would like to raise this issue officially so we can evaluate and coordinate the work needed to achieve this.
Arguments and filters are basically the same. They are used to reduce the amount the results of the query by adding WHERE statements. But arguments are a bit more complex because they can come from the URL / be dynamic, and can (or should) be validated.
Complexity put aside, arguments produce the same effects on the query. So it should be natural to combine them the same way, to be able to and/or them.
Durung the long talks I had, several non trivial issues were raised, related the superior complexity of arguments.
1. Arguments can be validated, so what happens when an argument that is "or-ed" does not validate ? Example : nid is argument 1, tid is argument 2 , both coming from URL. They are "or-ed". tid doesn't validate because it's not from the proper vocabulary. The term validator states that it shows the 404 page (or whatever option) when it returns false. But the nid validator returns right. Should this page show only the results according to its nid, or take into account the tid validator ? Because from the user point of view, one may want to show results when only one of them is present (this is the second big issue), but display 404 when they doesn't not validate ; or display results anyway.
2. Second issue is related to optional arguments. When "or-ed", an argument that is not present changes the ordering of the arguments in the URL, and so can break validation. Same example than above : nid is %1, tid is %2, nid is not there. How to tell Views to validate tid which is now %1 as if it was %2 ?
3. This issue is just the logic sequel to 1 and 2. Views has several options about how to handle cases when arguments is not present, and when it does not validate. With and/or possibility, we need a proper way and/or a consensus about how to handle all combinations possible, or a beautiful rule, AND a well thought UI.
4. This well thought UI. Arguments' complexity means the UI can grow far more complex. What I know for sure is that there will be more than what is in the filters section of the views UI (and/or select list). The UI will depend on the way chosen to handle the combinations. Will we have a global validator ? A global action for when all arguments validates or not ? Only those "or-ed", or "and-ed", or manually selected with a checkbox ? A refactored arguments section to make it right ?
5. UI again. Acquia recently sponsored a new UI for the d7 branch. What about it if further changes needs to be done related to arguments ?
6. I haven't talked about feasibility or technical problems, because I'm not knowledgeable enough about Views to do it. Maybe it is completely, or partially only doable. Views maintainers or activists input required here.
Comments
Comment #1
bojanz commentedVery happy to see this discussion starting :)
Related issues:
#357082: Pull filter value from an argument?.
#1088186: Merge filters and contextual filters into one feature
The UI work moved things around a bit, changed some labels, fieldsets, but the main part of arguments (filters...) stayed the same. So there should be no problem rolling patches against both 7.x (new UI) and 6.x in this case.
Of course, with the new UI the 7.x and 6.x branches are further apart, and it's bound to become a problem at some point, but we can cross that bridge when we get to it. At some point in time, 7.x will start receiving features that 6.x won't (it already has, with the new UI), and that's the natural progression of development.
I think you might be overthinking the problem. When it comes to optional arguments, take the exposed optional filter in an OR as an example.
It's always added to the query, and if you don't want it to be empty, you provide a default value. That's what arguments need to do as well.
This behavior can be re-evaluated in another issue, but it doesn't have to happen here, in the context of implementing and/or. For now we can just follow the filter behavior.
If one argument validator has a destructive setting (show 404 for example), then 404 gets shown. No question about it. That's at least how I see it.
Would like to hear from Earl and Daniel, as they remember the challenges from last time, and why it wasn't implemented as part of the filter and/or work.
Comment #2
bojanz commentedFurther discussion in #1088186: Merge filters and contextual filters into one feature makes me feel like it might not be a bad idea to just always pass values to filters, and then or the filters themselves.
That way both filter and argument values can be OR-ed and AND-ed in the same groups, instead of them being two separate groups.
Plus, finally found an issue about OR-ing arguments (I knew there was one), and it was wontfix'ed by Earl: http://drupal.org/node/141342#comment-4033446
So the pass-value-to-filter-then-or-the-filter approach might just be best.
Comment #3
DjebbZ commentedI read both issues, and I agree with you. As Earl said, it's a vast work to have OR in arguments, so better always pass them in filters do the actual filtering and OR-ing there.
Should we close this issue then and focus on #1088186: Merge filters and contextual filters into one feature ? (I don't want to mess with Views issue queue)
Comment #4
bojanz commentedLet's leave it a bit longer, someone else might also have an opinion. I'll close it in a day or two if that doesn't happen.
Comment #5
dawehnerFor and/or in arguments there is a approach with #357082: Pull filter value from an argument?: use global: null argument and use the filter.
You can do everything you need with this in theory.
Comment #6
bojanz commentedEarl said the same thing at http://drupal.org/node/1088186#comment-4197636.
Let's continue this at #357082: Pull filter value from an argument? then.