I haven't figured out why yet, but when view::_init_handler() is called from an ajax views request, views_plugin_display::get_handlers() has some of the handler types set to NULL.

When just using regular calls to views, only the handlers that exist are in the array.

CommentFileSizeAuthor
#7 1360336.patch815 bytesdawehner
#1 views-1360336-1.patch570 bytestim.plunkett

Comments

tim.plunkett’s picture

Priority: Normal » Major
StatusFileSize
new570 bytes

I'm going out on a limb and calling this major, because it completely defies (my) expectations, and causes huge problems for fullcalendar.

The easy fix is just empty instead of !isset.

tim.plunkett’s picture

Title: views_ajax can't find certain handlers » views_ajax() can't find certain handlers
Status: Active » Needs review
merlinofchaos’s picture

Hmm. The handlers being NULL sounds like it may be a deeper problem.

tim.plunkett’s picture

Assigned: Unassigned » tim.plunkett
Status: Needs review » Needs work

How did I know that you would say that? :)

tim.plunkett’s picture

Status: Needs work » Needs review
+++ b/plugins/views_plugin_display.incundefined
@@ -822,7 +822,7 @@ class views_plugin_display extends views_plugin {
       $this->handlers[$type] = array();

This line right here kinda makes me think that empty() would be a better choice.

tim.plunkett’s picture

Status: Needs review » Active

It looks like views_ajax is calling $view->validate() before preview, which initializes the handlers before hook_views_pre_view is called.
This might just be a duplicate of #837816: $view->add_item() doesn#t work in hook_views_pre_build(&$view) with Ajax, except that issue is about pre_build, while this is pre_view, and should have a better chance of working.

dawehner’s picture

Status: Active » Needs review
StatusFileSize
new815 bytes

Good observation!

Personal i believe that $view->validate() should only be called in the ui.
Maybe this is a relict of using view->preview() as direct callback for the ajax in the ui.
Noways views_ui_preview already catches validations so there is no need to do it in view->preview().

Additional running through all validations could cause quite some overhead. So here is my suggestion: remove it.

tim.plunkett’s picture

Assigned: tim.plunkett » Unassigned
Status: Needs review » Reviewed & tested by the community

This actually does remove the only call to $view->validate() that is outside includes/admin.inc and tests/views_view.test.
And furthermore, it fixes my problem! hook_views_pre_view is able to use add_item again!

dawehner’s picture

Status: Reviewed & tested by the community » Fixed

So committed to 6.x-3.x and 7.x-3.x

Yeah!

Status: Fixed » Closed (fixed)

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