Looked a bit but didn't see an issue about this, sorry if I missed it.

An ugly mysql message can be produced when $vids ends up being empty
Problem area

 function pre_render($values) {
    // If there are no values to render (displaying a summary, or query returned no results),
    // or if this is not a grouped field, do nothing specific.
    if (isset($this->view->build_info['summary']) || empty($values) || !$this->defer_query) {
      return parent::pre_render($values);
    }

    $field = $this->content_field;
    $db_info = content_database_info($field);
    $options = $this->options;

    // Build the list of vids to retrieve.
    // TODO: try fetching from cache_content first ??
    $vids = array();
    $this->field_values = array();
    foreach ($values as $result) {
      if (isset($result->{$this->field_alias})) {
        $vids[] = $result->{$this->field_alias};
      }
    }

The thing actually producing the mysql error

 " WHERE vid IN (". implode(',', $vids) .')'.        

since $vids is empty the query contains vid IN (), which mysql doesn't like.

I changed to using this instead so I can test for empty vids

 $vids = array();
     foreach ($values as $result) {
      if (isset($result->{$this->field_alias})) {
        $vids[] = $result->{$this->field_alias};
      }
    }
    if (isset($this->view->build_info['summary']) || empty($values) || !$this->defer_query || !$vids) {
      return parent::pre_render($values);
    }

    $field = $this->content_field;
    $db_info = content_database_info($field);
    $options = $this->options;

    // Build the list of vids to retrieve.
    // TODO: try fetching from cache_content first ??

    $this->field_values = array();

My erroring view is a user view with information from content profiles, which don't necessarily exist for some users.

CommentFileSizeAuthor
#2 membersview.txt8.88 KBhefox
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

markus_petrux’s picture

Status: Active » Postponed (maintainer needs more info)

I have tried to create a view with a multiple values fields that does not exist for some node and I had no problem. The pre_render() method didn't use that query when the view does not return data ($values is empty). When $values is not empty, there's at least one vid, so that query where the condition is vid IN (...) doesn't fail. So I was not able to reproduce the problem.

Could you please export your view and attach here in txt format?

hefox’s picture

FileSize
8.88 KB

The view is of users (not nodes), ie on view creation "Users" was selected instead of "Nodes". It has a relationship to content profile node content profile though, so it's possible to have values, ie from the users like name etc., but not a VIDs if the users hasn't created a profile yet.

markus_petrux’s picture

Status: Postponed (maintainer needs more info) » Fixed

I was able to reproduce the problem. Indeed, it may happen when a non-required relationship is involved.

Committed a patch to CCK2 and CCK3 branches. Thank you.

Status: Fixed » Closed (fixed)

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