When you attach a feed to a block display, the arguments aren't propagated to the feed. This is because default arguments are constructed in views::build(), which happens after views::pre_execute(). This patch fixes it for this case, but surely breaks it for glossary views and possibly other display attachments.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

deviantintegral’s picture

Here is the patch and my exported view:

$view = new view;
$view->name = 'node_comments_2';
$view->description = '';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'comments';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('relationships', array(
  'nid' => array(
    'label' => 'Node',
    'required' => 1,
    'id' => 'nid',
    'table' => 'comments',
    'field' => 'nid',
    'relationship' => 'none',
  ),
));
$handler->override_option('fields', array(
  'name' => array(
    'label' => 'Author',
    'link_to_user' => 1,
    'exclude' => 0,
    'id' => 'name',
    'table' => 'comments',
    'field' => 'name',
    'relationship' => 'none',
  ),
  'comment' => array(
    'label' => 'Body',
    'exclude' => 0,
    'id' => 'comment',
    'table' => 'comments',
    'field' => 'comment',
    'relationship' => 'none',
  ),
  'timestamp' => array(
    'label' => 'Post date',
    'date_format' => 'small',
    'custom_date_format' => '',
    'exclude' => 0,
    'id' => 'timestamp',
    'table' => 'comments',
    'field' => 'timestamp',
    'relationship' => 'none',
  ),
  'replyto_comment' => array(
    'label' => 'Reply-to link',
    'text' => '',
    'exclude' => 0,
    'id' => 'replyto_comment',
    'table' => 'comments',
    'field' => 'replyto_comment',
    'relationship' => 'none',
  ),
  'subject' => array(
    'label' => 'Title',
    'link_to_comment' => 1,
    'exclude' => 0,
    'id' => 'subject',
    'table' => 'comments',
    'field' => 'subject',
    'relationship' => 'none',
  ),
  'view_comment' => array(
    'label' => 'View link',
    'text' => '',
    'exclude' => 0,
    'id' => 'view_comment',
    'table' => 'comments',
    'field' => 'view_comment',
    'relationship' => 'none',
  ),
));
$handler->override_option('sorts', array(
  'timestamp' => array(
    'order' => 'DESC',
    'granularity' => 'second',
    'id' => 'timestamp',
    'table' => 'comments',
    'field' => 'timestamp',
    'relationship' => 'none',
  ),
));
$handler->override_option('arguments', array(
  'nid' => array(
    'default_action' => 'default',
    'style_plugin' => 'default_summary',
    'style_options' => array(),
    'wildcard' => 'all',
    'wildcard_substitution' => 'All',
    'title' => 'Recent Story Comments',
    'default_argument_type' => 'node',
    'default_argument' => '',
    'validate_type' => 'node',
    'validate_fail' => 'ignore',
    'break_phrase' => 0,
    'not' => 0,
    'id' => 'nid',
    'table' => 'node',
    'field' => 'nid',
    'relationship' => 'nid',
    'default_options_div_prefix' => '',
    'default_argument_user' => 0,
    'default_argument_fixed' => '',
    'default_argument_php' => 'if (arg(0) == \'node\' && is_numeric(arg(1))) {
      return arg(1);
    }',
    'validate_argument_node_type' => array(
      'story' => 'story',
      'image' => 0,
      'page' => 0,
      'project' => 0,
    ),
    'validate_argument_node_access' => 1,
    'validate_argument_nid_type' => 'nid',
    'validate_argument_vocabulary' => array(
      '1' => 0,
      '2' => 0,
    ),
    'validate_argument_type' => 'tid',
    'image_size' => array(
      '_original' => '_original',
      'thumbnail' => 'thumbnail',
      'preview' => 'preview',
    ),
    'validate_argument_php' => 'if (arg(0) == \'node\' && is_numeric(arg(1))) {
      $handler->argument = arg(1);
      return TRUE;
    }
    return FALSE;',
    'override' => array(
      'button' => 'Override',
    ),
  ),
));
$handler->override_option('filters', array(
  'status' => array(
    'operator' => '=',
    'value' => '0',
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'status',
    'table' => 'comments',
    'field' => 'status',
    'relationship' => 'none',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
));
$handler->override_option('title', 'Recent Comments');
$handler->override_option('items_per_page', 5);
$handler->override_option('style_plugin', 'list');
$handler->override_option('style_options', array(
  'grouping' => '',
  'type' => 'ul',
));
$handler = $view->new_display('feed', 'Feed', 'feed_1');
$handler->override_option('items_per_page', 15);
$handler->override_option('style_plugin', 'rss');
$handler->override_option('style_options', array(
  'mission_description' => FALSE,
  'description' => '',
));
$handler->override_option('row_plugin', 'comment_rss');
$handler->override_option('path', 'node/%/feed');
$handler->override_option('menu', array(
  'type' => 'none',
  'title' => '',
  'weight' => 0,
  'name' => 'navigation',
));
$handler->override_option('tab_options', array(
  'type' => 'none',
  'title' => '',
  'weight' => 0,
));
$handler->override_option('displays', array(
  'block_1' => 'block_1',
  'page_1' => 'page_1',
  'default' => 0,
));
$handler->override_option('sitename_title', FALSE);
$handler = $view->new_display('block', 'Block', 'block_1');
$handler->override_option('fields', array(
  'subject' => array(
    'label' => '',
    'link_to_comment' => 1,
    'exclude' => 0,
    'id' => 'subject',
    'table' => 'comments',
    'field' => 'subject',
    'override' => array(
      'button' => 'Use default',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('block_description', '');
$handler->override_option('block_caching', -1);
merlinofchaos’s picture

Status: Needs work » Fixed

This also required some fixes to view cloning to prevent attachment displays from destroying some of the original. This might fix other bugs elsewhere as well.

KarenS’s picture

Priority: Normal » Critical
Status: Fixed » Active

This patch completely destroyed the calendar module which is nothing but a bunch of attachments, and now none of the attachments work :(

Now instead of a view and an attachment I get a double view with no attachment. This patch changed the state of the view at the time it is attached and reversed the order of processing of the main view and the attachment, in addition to changing the point in the processing when the view is attached.

At first I thought it was just the Calendar module, but I am unable to get a simple attached view of nodes to work, so I think this patch has a problem.

KarenS’s picture

Here's a simple archive view where I tried to add an attachment, but the attachment won't show up.

$view = new view;
$view->name = 'archive';
$view->description = 'Display a list of months that link to content for that month.';
$view->tag = 'default';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('fields', array(
  'title' => array(
    'label' => 'Title',
    'link_to_node' => 1,
    'exclude' => 0,
    'id' => 'title',
    'table' => 'node',
    'field' => 'title',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
  'changed' => array(
    'label' => 'Updated date',
    'date_format' => 'small',
    'custom_date_format' => '',
    'exclude' => 0,
    'id' => 'changed',
    'table' => 'node',
    'field' => 'changed',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('sorts', array(
  'created' => array(
    'id' => 'created',
    'table' => 'node',
    'field' => 'created',
    'order' => 'DESC',
    'granularity' => 'second',
    'relationship' => 'none',
  ),
));
$handler->override_option('arguments', array(
  'created_year_month' => array(
    'default_action' => 'ignore',
    'style_plugin' => 'default_summary',
    'style_options' => array(
      'count' => 1,
      'override' => 1,
      'items_per_page' => '30',
    ),
    'wildcard' => 'all',
    'wildcard_substitution' => 'All',
    'title' => '%1',
    'default_argument_type' => 'fixed',
    'default_argument' => '',
    'validate_type' => 'none',
    'validate_fail' => 'not found',
    'id' => 'created_year_month',
    'table' => 'node',
    'field' => 'created_year_month',
    'relationship' => 'none',
    'override' => array(
      'button' => 'Override',
    ),
    'default_options_div_prefix' => '',
    'default_argument_user' => 0,
    'default_argument_fixed' => '',
    'default_argument_php' => '',
    'validate_argument_node_type' => array(
      'dates' => 0,
      'page' => 0,
      'story' => 0,
    ),
    'validate_argument_node_access' => 0,
    'validate_argument_nid_type' => 'nid',
    'validate_argument_vocabulary' => array(),
    'validate_argument_type' => 'tid',
    'validate_argument_php' => '',
  ),
));
$handler->override_option('filters', array(
  'status' => array(
    'id' => 'status',
    'table' => 'node',
    'field' => 'status',
    'operator' => '=',
    'value' => 1,
    'group' => 0,
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
  'role' => array(),
  'perm' => '',
));
$handler->override_option('title', 'Monthly archive');
$handler->override_option('use_pager', '1');
$handler->override_option('style_plugin', 'table');
$handler->override_option('row_plugin', 'node');
$handler->override_option('row_options', array(
  'teaser' => TRUE,
  'links' => TRUE,
));
$handler = $view->new_display('page', 'Page', 'page');
$handler->override_option('style_plugin', 'list');
$handler->override_option('style_options', array(
  'type' => 'ul',
));
$handler->override_option('path', 'archive');
$handler->override_option('menu', array(
  'type' => 'none',
  'title' => '',
  'weight' => 0,
  'name' => 'navigation',
));
$handler->override_option('tab_options', array(
  'type' => 'none',
  'title' => '',
  'weight' => 0,
));
$handler = $view->new_display('block', 'Block', 'block');
$handler->override_option('arguments', array(
  'created_year_month' => array(
    'id' => 'created_year_month',
    'table' => 'node',
    'field' => 'created_year_month',
    'default_action' => 'summary asc',
    'style_plugin' => 'default_summary',
    'style_options' => array(
      'count' => 1,
      'override' => 0,
      'items_per_page' => '30',
    ),
    'wildcard' => 'all',
    'wildcard_substitution' => 'All',
    'title' => '%1',
    'relationship' => 'none',
    'validate_type' => 'none',
    'validate_fail' => 'not found',
    'default_argument_type' => 'fixed',
  ),
));
$handler->override_option('use_ajax', '1');
$handler->override_option('block_description', 'Archive list');
$handler->override_option('block_caching', -1);
$handler = $view->new_display('attachment', 'Attachment', 'attachment_1');
$handler->override_option('attachment_position', 'before');
$handler->override_option('inherit_arguments', TRUE);
$handler->override_option('inherit_exposed_filters', FALSE);
$handler->override_option('displays', array(
  'page' => 'page',
  'default' => 0,
  'block' => 0,
));
merlinofchaos’s picture

Karen: Try this patch on the current dev

KarenS’s picture

Status: Active » Reviewed & tested by the community

Whew! Yes, that worked for me. I didn't re-run update.php so that part of the patch didn't do anything, but the other part did. Should I re-run update.php too?

merlinofchaos’s picture

Oh no, don't run instlal.php; in fact that part of the patch was an error that I didn't even realize I had (must've not noticed which window I was working in).

kinaya’s picture

Trying to figure out merlinofchaos response.. Should I only use half of the patch in #5, to change things in views.inc, and don't change anything in views.install?

Jeremy Toaster’s picture

Any idea when this will be fixed and committed to a new tarball release? My Calendar has been non functioning since Jan 7th.

KarenS’s picture

I found an additional problem when using exposed filters in a view -- if I add an attachment to the view I get two views of the exposed filters and no attachment. I don't have a clean example to show you but I thought I'd just see if you have a quick and obvious answer to that. If you need more details I'll try to get back and create an example that behaves that way.

This is after making the above fix, so it's an additional problem.

KarenS’s picture

Status: Reviewed & tested by the community » Needs work
KarenS’s picture

@Jeremy, your best bet is to revert to the latest stable release of Views until this is fixed. Both the original issue I reported and the newer one I just found with exposed filters work correctly if I just jump back to a Views version prior to Jan 5.

Jeremy Toaster’s picture

Ok Karen,
I've have just done that, the mini calendar is back, but nothing shows up it in, the calendar posts or content, flushed everything and even tried republishing some items and still nothing.
Is there something else I should try?

jeremy

merlinofchaos’s picture

Status: Needs work » Active

Karen: I can't get the attachment/exposed filter thing to happen like you suggest in #10; it may be more complex than simply having exposed filters on.

The patch that was here was already committed, at least. By mistake but it worked.

KarenS’s picture

Status: Active » Fixed

I don't see problems any more in the latest code, so I think it's fixed. Thanks!

@Jeremy, your issue is specific to Calendar, not a Views issue, so I'm marking this one fixed.

Jeremy Toaster’s picture

I think my problems make be fixed as well, I just reverted all the Calendar stuff back to default and rebuilt all my Views of it. I believe some DATE changes were causing issues on what it should display as some terms had changed. So far everything seems to be showing back up now, so you can mark that other one fixed as well.

Status: Fixed » Closed (fixed)

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