I've noticed that you can't reference the same view in a View area, obviously to prevent infinite loops. I would really really like to reference the same view but with a different display as the No Results Behaviour.

For this to work views would have to make sure that the display that references the other displays is overriding the no results behaviour. Alternatively there could be a setting that allows you to reference the same view with a warning saying that this will cause a WSOD.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mstrelan’s picture

Status: Active » Needs review
FileSize
1.27 KB

It looks like the code to detect recursion already exists in the render function so here is a patch that allows you to select a display of the same view.

merlinofchaos’s picture

We could just introduce gating logic and that would take care of the complexity.

merlinofchaos’s picture

It could also deal with the possible ping pong effect.

mstrelan’s picture

I'm not sure what you mean, but if you can explain a bit further I might be able to learn a thing or two and roll a patch... otherwise the ball's in your court.

merlinofchaos’s picture

By gating logic I mean recursion prevention. Allow any view and any display to be selected, and when building a view, check a variable to see if that view is currently in the process of being built. That would prevent the infinite loop crash issue.

mstrelan’s picture

It looks to me like that is already done...

<?php
class views_handler_area_view extends views_handler_area {
  // .....
  function render($empty = FALSE) {
  // ....
      // Avoid recursion
      $view->parent_views += $this->view->parent_views;
      $view->parent_views[] = "$view_name:$view_display";

      // Check if the view is part of the parent views of this view
      $search = "$view_name:$view_display";
      if (in_array($search, $this->view->parent_views)) {
        drupal_set_message(t("Recursion detected in view @view display @display.", array('@view' => $view_name, '@display' => $view_display)), 'error');
      }
      // ...
  }
}
?>
merlinofchaos’s picture

That makes it easy then.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

The recursion check is already implemented so this is rtbc.

merlinofchaos’s picture

Status: Reviewed & tested by the community » Needs work

Patch doesn't apply now.

dawehner’s picture

Status: Needs work » Needs review
FileSize
1.28 KB

Update patch

dawehner’s picture

Status: Needs review » Fixed

Commited.

Status: Fixed » Closed (fixed)

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

mstrelan’s picture

mstrelan’s picture

Category: feature » bug
Priority: Normal » Major
Status: Needs work » Needs review
FileSize
615 bytes

New patch. Setting to major because it can break existing views if sites are upgraded.

dawehner’s picture

Status: Needs review » Needs work

I guess that's not the best solution because this would allow you to embed the same display it it's display. So in general views_get_views_as_options has to be fixed.

mstrelan’s picture

Status: Needs work » Needs review

If you read the previous comments from when this was initially committed it was agreed that recursion prevention already exists and therefore it is not entirely necessary to prevent users from trying to reference the same display. So essentially views_get_views_as_options has to be fixed only to improve the usability of embedded views in views areas. #1215602: views_get_views_as_options() for simple use in #options has introduced a regression and the fix for it is being blocked on a minor usability issue? I think this patch should be committed to fix the regression and then we can create a new issue to remove the option to embed the same display.

dawehner’s picture

Well i see your point, but your patch would add a regression as well: you can now embed the same display of a view to a view, so you have something which you don't want.

Is it so hard to fix another part of the code?

mstrelan’s picture

you can now embed the same display of a view to a view

Well you can add it, but views_handler_area_view::render() will prevent it from executing. It would be an edge case as no one who was thinking straight would try to do this.

Is it so hard to fix another part of the code?

I guess not, I could say the same thing. I'm not on my development machine at the moment so I've got no Drupal install to test it on. Might take a look some other time.

markie’s picture

FYI: This issue has crept up again with the latest release build. Making the line change once again fixes the issue.

dawehner’s picture

Status: Needs review » Fixed
FileSize
1.83 KB

Here is a different patch which uses all the features of this function. nice!

Just committed it, so people can profit from it.

Status: Fixed » Closed (fixed)

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