How to reproduce using panels
How to reproduce:
* Add a view with a panels pane display and 2 arguments (aka contextual filters), both populated from an optional context
* Configure it with Arg1=No-context, Arg2=Some-context
Expected: View is filtered with argument2
Experienced: View is not filtered, argument2 silently ignored
How to reproduce with code
I have a view with 2 contextual filters, changed date and node type. Both filters are set up so that all values are returned if the argument is NULL. As such, I expect to be able to both arguments independently, giving 4 possible combinations:
This code demonstrates it:
$view = views_get_view('test');
$args = array('2011', 'paper'); // works fine, all 'paper' nodes created in 2011
$args = array('2011', NULL); // works as expected, all nodes created in 2011
$args = array(NULL, 'paper'); // returns all nodes, NOT only nodes of type paper
$args = array(NULL, NULL); // returns all nodes as expected
return $view->preview('default', $args);
The _build_arguments function in view.inc seems to stop whenever it encounters an argument that is not obtained from the url and has no value. Subsequent arguments are therefore ignored.
Comment | File | Size | Author |
---|---|---|---|
#1 | views-multiple-arguments-1250336-1.patch | 426 bytes | erik.erskine |
Comments
Comment #1
erik.erskine CreditAttribution: erik.erskine commentedThe patch seems to work for me, though I'm not totally sure what the $status variable means, so perhaps someone can verify it.
Thanks!
Comment #2
dawehnerSeems somehow related to #1272688: Add new argument default action that uses wildcard as default value
Comment #3
tim.plunkett@ingaro, one option you have now is to use "Fixed" and provide the default value of "all", which matches the wildcard and would show all results.
Or, you can try the patch in #1272688-10: Add new argument default action that uses wildcard as default value and use the new action, "Use the wildcard to display all results".
I think your patch makes sense, but could break existing sites in unexpected ways, and merlinofchaos has convinced me that adding a new action is the way to go.
Comment #4
erik.erskine CreditAttribution: erik.erskine commentedThanks @tim.plunkett
The view had a content pane which was getting 6 unrelated arguments from a context. I'm now passing the string 'all' rather than NULL for the arguments where I don't want to filter. This works fine without the patch in #1.
Comment #5
dawehnerIf the current patch changes the current behavior the status should be needs work. There are always at least 100 sites which uses a certain small feature.
Comment #6
Jorrit CreditAttribution: Jorrit commentedThis patch works for me. The promised default action mentioned in #3 will probably not be added.
I think the code is good because a missing argument value should not break the arguments loop but continue while there are more argument values.
Comment #6.0
Jorrit CreditAttribution: Jorrit commentedbetter clarification of description
Comment #7
das-peter CreditAttribution: das-peter commentedI've had a similar issue: #2341249: Do not skip processing all arguments if one "fails"
However my perspective was that
break;
should be replaced bycontinue;
- independent of$status
.If my patch goes in we've to decide here if
$status
has to be considered somehow.Comment #8
geek-merlinAdding to summary how this affects panels. Setting to major as this clearly satisfies "Render one feature unusable with no workaround.".
Comment #9
geek-merlinComment #10
geek-merlin