Problem/Motivation
Hi!
I created a view that filter contents by their Group Audience, so I added a contextual filter on "Content: Group Audience"
and I checked the "Specify validation criteria" with OG Group as validator, Node as Group type and "Allow multiple values" box in the "More" section of the filter settings.
The view worked fine until the Drupal core update from 7.36 to 7.37 (here release notes), then it broke due to the add to entity.inc (line 186) of
// Ensure integer entity IDs are valid.
if (!empty($ids)) {
$this->cleanIds($ids);
}
Searching a bit into the code I found that the entity.inc was called by entity_load_single() in the validate_argument() of og_plugin_argument_validate_group.inc (line 37). The issue is due to from validation that doesn't manage correctly multiple arguments:
function validate_argument($argument) {
if (empty($argument)) {
return;
}
$group_type = $this->options['group_type'];
$entity = entity_load_single($group_type, $argument);
if (!$entity || !og_is_group($group_type, $entity)) {
return FALSE;
}
$this->argument->argument = $argument;
$this->argument->validated_title = entity_label($group_type, $entity);
return TRUE;
}
Proposed resolution
My propose is to upgrade the validate_argument of og_plugin_argument_validate_group.inc to correctly manage multiple arguments, as it already does with single arg.
Comments
Comment #2
pabloid commentedComment #3
ralkeon commentedI think this must solve it. I changed the og_plugin_argument_validate_group.inc validation to manage arguments he receive checking if they're strings or numeric. if they are string it checks if they are multiple ids then it validate every single id and unite them again as a string after the validation. :) hope it will work and it's usefull.
Comment #4
ralkeon commentedCorrect some typo error and removed some useless code. :)
Comment #5
joelpittetSending this to testbot.
Comment #6
joelpittetAny chance we could use views_break_phrase() to explode the arguments?
Noticed flag module was using it
Comment #7
joelpittetHere's how that would look. I kept the label creation but I wonder if that bit is needed?
Comment #8
joelpittetJust a bump, we've been using the patch in production for a good few years
Comment #9
joelpittetFixed and committed