In views 2.1, hook_views_pre_view passed a $display_id, however since:
http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/views/inclu...
- this was broken, because pre_execute() is not passed a $display_id.

There are 2 equivalent patches - the first just gets the current display with $display_id = $this->current_display;. The second alters the function call so that the $display_id is passed in from the caller. Both appear to work correctly in my cases, although I haven't really looked at previewing - take your pick which one you prefer :)

Comments

brmassa’s picture

Status: Needs review » Reviewed & tested by the community

Earl,

i confirm the bug and the both patches fix it. But i recommend the first because its cleaner.

the only note i would make is on the first patch (*get_current.patch) is that instead + $display_id = $this->current_display; i would put + $display_id = &$this->current_display; so modules would be able to modify it by calling the hook with reference values. Despite that, the patch is great.

regards,

massa

merlinofchaos’s picture

Simply modifying the display ID won't actually help, as you also have to change $view->display_handler to reference the right handler. So making that a reference would probably do more harm than good.

brmassa’s picture

Earl,

well. Fair enough. It was in fact an extra "feature" that i imagined possible. The bug reported was actually fixed with the original patches.

regards,

massa

karens’s picture

Priority: Normal » Critical

Subscribing, any module using views_pre_view() has errors and cannot use either $display_id or $args until this is fixed (because the missing $display_id also shifts $args to the wrong position so that $display_id is now $args and $args is always empty). So basically views_pre_view(), a pretty basic Views hook, is unusable, which I think might qualify as critical.

merlinofchaos’s picture

Status: Reviewed & tested by the community » Fixed

Ok, first patch committed. Thanks!

Status: Fixed » Closed (fixed)

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