Download & Extend

Call to a member function options_validate() on a non-object when adding a field

Project:Views
Version:7.x-3.x-dev
Component:Code
Category:bug report
Priority:major
Assigned:Unassigned
Status:active

Issue Summary

When attempting to add a field, the setting form loads fine. However, when I attempt to save, I get the little "loading" thing for a second or two, then the "loading" thing disappears but the dialog stays there. The Apache log reveals this:

[Sat Dec 01 22:13:42 2012] [error] [client 127.0.0.1] PHP Fatal error:  Call to a member function options_validate() on a non-object in [Drupal root]/sites/all/modules/views/includes/admin.inc on line 4399, referer: http://chinese.lh/admin/structure/views/view/portfolio_/edit
[Sat Dec 01 22:13:42 2012] [error] [client 127.0.0.1] PHP Stack trace:, referer: http://chinese.lh/admin/structure/views/view/portfolio_/edit
[Sat Dec 01 22:13:42 2012] [error] [client 127.0.0.1] PHP   1. {main}() [Drupal root]/index.php:0, referer: http://chinese.lh/admin/structure/views/view/portfolio_/edit
[Sat Dec 01 22:13:42 2012] [error] [client 127.0.0.1] PHP   2. menu_execute_active_handler($path = *uninitialized*, $deliver = *uninitialized*) [Drupal root]/index.php:21, referer: http://chinese.lh/admin/structure/views/view/portfolio_/edit
[Sat Dec 01 22:13:42 2012] [error] [client 127.0.0.1] PHP   3. call_user_func_array(*uninitialized*, *uninitialized*) [Drupal root]/includes/menu.inc:517, referer: http://chinese.lh/admin/structure/views/view/portfolio_/edit
[Sat Dec 01 22:13:42 2012] [error] [client 127.0.0.1] PHP   4. views_ui_ajax_form($js = *uninitialized*, $key = *uninitialized*, $view = *uninitialized*, $display_id = *uninitialized*, *uninitialized*, *uninitialized*) [Drupal root]/includes/menu.inc:517, referer: http://chinese.lh/admin/structure/views/view/portfolio_/edit
[Sat Dec 01 22:13:42 2012] [error] [client 127.0.0.1] PHP   5. views_ajax_form_wrapper($form_id = *uninitialized*, $form_state = *uninitialized*) [Drupal root]/sites/all/modules/views/includes/admin.inc:2943, referer: http://chinese.lh/admin/structure/views/view/portfolio_/edit
[Sat Dec 01 22:13:42 2012] [error] [client 127.0.0.1] PHP   6. drupal_build_form($form_id = *uninitialized*, $form_state = *uninitialized*) [Drupal root]/sites/all/modules/views/includes/ajax.inc:236, referer: http://chinese.lh/admin/structure/views/view/portfolio_/edit
[Sat Dec 01 22:13:42 2012] [error] [client 127.0.0.1] PHP   7. drupal_process_form($form_id = *uninitialized*, $form = *uninitialized*, $form_state = *uninitialized*) [Drupal root]/includes/form.inc:374, referer: http://chinese.lh/admin/structure/views/view/portfolio_/edit
[Sat Dec 01 22:13:42 2012] [error] [client 127.0.0.1] PHP   8. drupal_validate_form($form_id = *uninitialized*, $form = *uninitialized*, $form_state = *uninitialized*) [Drupal root]/includes/form.inc:846, referer: http://chinese.lh/admin/structure/views/view/portfolio_/edit
[Sat Dec 01 22:13:42 2012] [error] [client 127.0.0.1] PHP   9. _form_validate($elements = *uninitialized*, $form_state = *uninitialized*, $form_id = *uninitialized*) [Drupal root]/includes/form.inc:1134, referer: http://chinese.lh/admin/structure/views/view/portfolio_/edit
[Sat Dec 01 22:13:42 2012] [error] [client 127.0.0.1] PHP  10. form_execute_handlers($type = *uninitialized*, $form = *uninitialized*, $form_state = *uninitialized*) [Drupal root]/includes/form.inc:1404, referer: http://chinese.lh/admin/structure/views/view/portfolio_/edit
[Sat Dec 01 22:13:42 2012] [error] [client 127.0.0.1] PHP  11. views_ui_config_item_form_validate($form = *uninitialized*, $form_state = *uninitialized*) [Drupal root]/includes/form.inc:1464, referer: http://chinese.lh/admin/structure/views/view/portfolio_/edit

A quick look shows the guilty line:

<?php
$form_state
['handler']->options_validate($form['options'], $form_state);
?>

It appears that $form_state['handler'] is NULL, but I haven't investigated into why yet.

Comments

#1

I have the same, and I could not fix this yet :-(

#2

I have the same issue when saving a new field to a view involving message's.

*EDIT* Actually this occurs because the view was locked, although I never performed any action that indicated I was locking the view. If I unlock the view then it works fine. I think the reason for this is that none of the people mentioning the issue actually did any intentional locking and there is no error handling for this use case.

#3

@Lann: Hmm. I don't think my view is locked…

#4

Component:User interface» Code

This got me too. In my case it's when adding a custom integer field as a sort to a EFQ Content View (built using the efq_views module).

I tried wrapping that line in "if (is_object($form_state['handler'])) { }" as a quick hack but that just broke things more. I'll debug ASAP.

#5

Turns out that in my case, this was just because I was using a master/slave setup (using the autoslave module) and the slave was like 10 minutes behind the master due to a large migration I had running.

So since the slave was ONLY being used for SELECTs, views would add the field or filter to the view but then when it tried to get it back out to configure, it wouldn't be there, hence the error.

#6

In my particular circumstance, this is happening when trying to add a sort to a view that is inheriting sorts from the default display. When it builds the form, the new field is an option on the default display ($this->default_display->get_option('sorts') returns my new sort), but after submitting the form, during validation, this new sort is NOT on the default display of the view. In turn, the handler is never added to $form_state. Digging in deeper now, but as with any Views bug, I'm never sure how deep this rabbit hole goes. :)

#7

Priority:normal» major

Bumping to major, since this is blocking the ability to add sorts to a View.

#8

Hmm, oddly enough, after a bit of tinkering with this, an old Lock appeared on the view. Breaking the lock fixed the issue. I wonder if this was somehow a stale cache item that didn't get purged properly?