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

pabloid created an issue. See original summary.

pabloid’s picture

Title: Og views group audience filter doesn't manage multiple arguments » Og views group audience filter validation doesn't manage multiple arguments
ralkeon’s picture

I 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.

ralkeon’s picture

Correct some typo error and removed some useless code. :)

joelpittet’s picture

Version: 7.x-2.7 » 7.x-1.x-dev
Status: Active » Needs review
Issue tags: -OG, -views, -arguments, -args, -multiple, -multi

Sending this to testbot.

joelpittet’s picture

Any chance we could use views_break_phrase() to explode the arguments?

Noticed flag module was using it

joelpittet’s picture

Here's how that would look. I kept the label creation but I wonder if that bit is needed?

joelpittet’s picture

Just a bump, we've been using the patch in production for a good few years

joelpittet’s picture

Status: Needs review » Fixed

Fixed and committed

  • joelpittet committed 7a2ae254 on 7.x-2.x
    Issue #2593333 by Ralkeon, joelpittet, pabloid: Og views group audience...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.