This is similar to #1272524: Undefined index: current user warning but happens at a different spot in the code. Adding a contextual filter for current user causes this error: "Notice: Undefined index: current_user in views_handler_argument->options_validate() (line 413 of /var/www/vhosts/localhost/httpdocs/sites/all/modules/views/handlers/views_handler_argument.inc)."
Here is the export:
$view = new view;
$view->name = 'view_mytypes';
$view->description = 'All mytypes by this user';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'view mytypes';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'My mytypes';
$handler->display->display_options['css_class'] = 'mytype-display mytype-display-block';
$handler->display->display_options['access']['type'] = 'role';
$handler->display->display_options['access']['role'] = array(
3 => '3',
5 => '5',
6 => '6',
);
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'fields';
$handler->display->display_options['row_options']['inline'] = array(
'title' => 'title',
'field_mytype_apprvd' => 'field_mytype_apprvd',
'field_mytype_reviewed' => 'field_mytype_reviewed',
);
$handler->display->display_options['row_options']['hide_empty'] = 1;
$handler->display->display_options['row_options']['default_field_elements'] = 1;
/* Field: Content: Approval */
$handler->display->display_options['fields']['field_mytype_approval']['id'] = 'field_mytype_approval';
$handler->display->display_options['fields']['field_mytype_approval']['table'] = 'field_data_field_mytype_approval';
$handler->display->display_options['fields']['field_mytype_approval']['field'] = 'field_mytype_approval';
$handler->display->display_options['fields']['field_mytype_approval']['label'] = '';
$handler->display->display_options['fields']['field_mytype_approval']['alter']['alter_text'] = 1;
$handler->display->display_options['fields']['field_mytype_approval']['alter']['text'] = '[field_mytype_approval-value]';
$handler->display->display_options['fields']['field_mytype_approval']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['field_mytype_approval']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['field_mytype_approval']['alter']['external'] = 0;
$handler->display->display_options['fields']['field_mytype_approval']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['field_mytype_approval']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['field_mytype_approval']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['field_mytype_approval']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['field_mytype_approval']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['field_mytype_approval']['alter']['more_link'] = 0;
$handler->display->display_options['fields']['field_mytype_approval']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['field_mytype_approval']['alter']['trim'] = 0;
$handler->display->display_options['fields']['field_mytype_approval']['alter']['html'] = 0;
$handler->display->display_options['fields']['field_mytype_approval']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['field_mytype_approval']['element_default_classes'] = 1;
$handler->display->display_options['fields']['field_mytype_approval']['empty'] = 'empty';
$handler->display->display_options['fields']['field_mytype_approval']['hide_empty'] = 0;
$handler->display->display_options['fields']['field_mytype_approval']['empty_zero'] = 0;
$handler->display->display_options['fields']['field_mytype_approval']['hide_alter_empty'] = 1;
$handler->display->display_options['fields']['field_mytype_approval']['field_api_classes'] = 0;
/* Field: Content: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['title']['alter']['external'] = 0;
$handler->display->display_options['fields']['title']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['title']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['title']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
$handler->display->display_options['fields']['title']['alter']['more_link'] = 0;
$handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['title']['alter']['trim'] = 0;
$handler->display->display_options['fields']['title']['alter']['html'] = 0;
$handler->display->display_options['fields']['title']['element_label_colon'] = 0;
$handler->display->display_options['fields']['title']['element_wrapper_type'] = 'span';
$handler->display->display_options['fields']['title']['element_wrapper_class'] = 'mytype-tite';
$handler->display->display_options['fields']['title']['element_default_classes'] = 0;
$handler->display->display_options['fields']['title']['hide_empty'] = 0;
$handler->display->display_options['fields']['title']['empty_zero'] = 0;
$handler->display->display_options['fields']['title']['hide_alter_empty'] = 1;
$handler->display->display_options['fields']['title']['link_to_node'] = 1;
/* Field: Content: Assignment */
$handler->display->display_options['fields']['field_mytype_assmt']['id'] = 'field_mytype_assmt';
$handler->display->display_options['fields']['field_mytype_assmt']['table'] = 'field_data_field_mytype_assmt';
$handler->display->display_options['fields']['field_mytype_assmt']['field'] = 'field_mytype_assmt';
$handler->display->display_options['fields']['field_mytype_assmt']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['field_mytype_assmt']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['field_mytype_assmt']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['field_mytype_assmt']['alter']['external'] = 0;
$handler->display->display_options['fields']['field_mytype_assmt']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['field_mytype_assmt']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['field_mytype_assmt']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['field_mytype_assmt']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['field_mytype_assmt']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['field_mytype_assmt']['alter']['more_link'] = 0;
$handler->display->display_options['fields']['field_mytype_assmt']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['field_mytype_assmt']['alter']['trim'] = 0;
$handler->display->display_options['fields']['field_mytype_assmt']['alter']['html'] = 0;
$handler->display->display_options['fields']['field_mytype_assmt']['element_label_colon'] = 1;
$handler->display->display_options['fields']['field_mytype_assmt']['element_default_classes'] = 1;
$handler->display->display_options['fields']['field_mytype_assmt']['hide_empty'] = 0;
$handler->display->display_options['fields']['field_mytype_assmt']['empty_zero'] = 0;
$handler->display->display_options['fields']['field_mytype_assmt']['hide_alter_empty'] = 1;
$handler->display->display_options['fields']['field_mytype_assmt']['settings'] = array(
'link' => 0,
);
$handler->display->display_options['fields']['field_mytype_assmt']['field_api_classes'] = 0;
/* Field: Content: Post date */
$handler->display->display_options['fields']['created']['id'] = 'created';
$handler->display->display_options['fields']['created']['table'] = 'node';
$handler->display->display_options['fields']['created']['field'] = 'created';
$handler->display->display_options['fields']['created']['label'] = 'Created';
$handler->display->display_options['fields']['created']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['created']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['created']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['created']['alter']['external'] = 0;
$handler->display->display_options['fields']['created']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['created']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['created']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['created']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['created']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['created']['alter']['more_link'] = 0;
$handler->display->display_options['fields']['created']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['created']['alter']['trim'] = 0;
$handler->display->display_options['fields']['created']['alter']['html'] = 0;
$handler->display->display_options['fields']['created']['element_label_colon'] = 1;
$handler->display->display_options['fields']['created']['element_default_classes'] = 1;
$handler->display->display_options['fields']['created']['hide_empty'] = 0;
$handler->display->display_options['fields']['created']['empty_zero'] = 0;
$handler->display->display_options['fields']['created']['hide_alter_empty'] = 1;
$handler->display->display_options['fields']['created']['date_format'] = 'short';
/* Field: Content: Updated/commented date */
$handler->display->display_options['fields']['last_updated']['id'] = 'last_updated';
$handler->display->display_options['fields']['last_updated']['table'] = 'node_comment_statistics';
$handler->display->display_options['fields']['last_updated']['field'] = 'last_updated';
$handler->display->display_options['fields']['last_updated']['label'] = 'Last Update';
$handler->display->display_options['fields']['last_updated']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['last_updated']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['last_updated']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['last_updated']['alter']['external'] = 0;
$handler->display->display_options['fields']['last_updated']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['last_updated']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['last_updated']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['last_updated']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['last_updated']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['last_updated']['alter']['more_link'] = 0;
$handler->display->display_options['fields']['last_updated']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['last_updated']['alter']['trim'] = 0;
$handler->display->display_options['fields']['last_updated']['alter']['html'] = 0;
$handler->display->display_options['fields']['last_updated']['element_label_colon'] = 1;
$handler->display->display_options['fields']['last_updated']['element_default_classes'] = 1;
$handler->display->display_options['fields']['last_updated']['hide_empty'] = 0;
$handler->display->display_options['fields']['last_updated']['empty_zero'] = 0;
$handler->display->display_options['fields']['last_updated']['hide_alter_empty'] = 1;
$handler->display->display_options['fields']['last_updated']['date_format'] = 'time ago';
/* Sort criterion: Content: Post date */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'node';
$handler->display->display_options['sorts']['created']['field'] = 'created';
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
/* Filter criterion: Content: Type */
$handler->display->display_options['filters']['type']['id'] = 'type';
$handler->display->display_options['filters']['type']['table'] = 'node';
$handler->display->display_options['filters']['type']['field'] = 'type';
$handler->display->display_options['filters']['type']['value'] = array(
'mytype' => 'mytype',
);
/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['enabled'] = FALSE;
$handler->display->display_options['path'] = 'mytypes';
$handler->display->display_options['menu']['type'] = 'normal';
$handler->display->display_options['menu']['title'] = 'My mytypes';
$handler->display->display_options['menu']['weight'] = '0';
$handler->display->display_options['menu']['name'] = 'main-menu';
$handler->display->display_options['menu']['context'] = 0;
/* Display: view mytype Block */
$handler = $view->new_display('block', 'view mytype Block', 'block');
$handler->display->display_options['defaults']['pager'] = FALSE;
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '5';
$handler->display->display_options['defaults']['style_plugin'] = FALSE;
$handler->display->display_options['style_plugin'] = 'table';
$handler->display->display_options['style_options']['columns'] = array(
'field_mytype_approval' => 'field_mytype_approval',
'title' => 'title',
'created' => 'created',
'last_updated' => 'last_updated',
);
$handler->display->display_options['style_options']['default'] = '-1';
$handler->display->display_options['style_options']['info'] = array(
'field_mytype_approval' => array(
'sortable' => 0,
'default_sort_order' => 'asc',
'align' => '',
'separator' => '',
'empty_column' => 0,
),
'title' => array(
'sortable' => 0,
'default_sort_order' => 'asc',
'align' => '',
'separator' => '',
'empty_column' => 0,
),
'created' => array(
'sortable' => 0,
'default_sort_order' => 'asc',
'align' => '',
'separator' => '',
'empty_column' => 0,
),
'last_updated' => array(
'sortable' => 0,
'default_sort_order' => 'asc',
'align' => '',
'separator' => '',
'empty_column' => 0,
),
);
$handler->display->display_options['style_options']['override'] = 1;
$handler->display->display_options['style_options']['sticky'] = 0;
$handler->display->display_options['style_options']['empty_table'] = 0;
$handler->display->display_options['defaults']['style_options'] = FALSE;
$handler->display->display_options['defaults']['row_plugin'] = FALSE;
$handler->display->display_options['defaults']['row_options'] = FALSE;
$handler->display->display_options['block_description'] = 'My mytypes';
Comments
Comment #1
Ken Ficara commentedAttaching patch.
Comment #2
dawehnerThis line doesn't look like valid php for me.
How did you actually managed to remove all code after 80 characters, i have never seen that before.
Comment #3
Ken Ficara commentedUm ... wow. That's a good question, dawehner. Must be how my terminal program handles wordwrap? No clue. Piped the diff to a file the way I should have in the first place.
Comment #4
dawehnerIt would be somehow cool if you could explain how this could actually have happened.
Often a notice actually shows some other kind of bug.
Comment #5
Ken Ficara commentedAs I said, this happened at the moment I added any contextual filter to the view for user ID, even without attempting to set a default value. I don't know enough about views to trace the call and figure out why the $default_id wasn't present in the form, but these sort of errors seem persistent throughout drupal -- using hash values without checking whether they actually exist or not. Maybe options_validate() should be able to depend on that value being there and it's the fault of the form or something else that it wasn't actually present? I don't know. Putting those two checks in eliminates the error, and the view still seems to get constructed correctly. If it's off-target, then please educate me, since I'd like to understand it better. Thanks.
Comment #6
Ken Ficara commentedOK, I got this exact same error for a different view entirely on a different setup, and I think I know what's going on. In this case I was adding a contextual filter which provided a default value using the content ID from the URL. I got the error, "Notice: Undefined index: node in options_validate() (line 413 of /home/america/dev/profiles/openpublish/modules/contrib/views/handlers/views_handler_argument.inc). " Exactly the same problem, but this time the $default_id was 'node' instead of 'current_user'.
This error only occurs on the view edit screen itself, and I think it's because there is no content ID to be found in the URL of that page (/admin/structure/views/view/myview). It works fine in its intended context (as a block on a node page) when there is, in fact, a content ID in the URL.
It's probably also worth mentioning that in both cases, I'm processing the provided argument through a PHP-code validator, in this case to basically dereference from the parent node, to a node it references.
Comment #7
jwilson3I can confirm the error in #6 (Undefined index: node on line 413) following the directions on http://www.metachunk.com/blog/adding-related-content-view-drupal-7 for building a simple related content view, namely, the section for adding the contextual nid default value.
* Configure contextual filter: Content: Nid (opens in a modal dialog).
* Provide default value: Content ID from URL
* Expand More > Click Exclude (checkbox).
* Click Apply button in modal dialog.
* Boom, breakage: the following is the stack trace that appears in a javascript alert box, with xdebug enabled:
Patch in #6 fixes the problem for me.
Here's a simple reroll that removes /sites/all/modules/ from the patch, so it applies with drush make.
Comment #8
jwilson3Here's a simple view with nothing special, that displays the error in #6, in case someone else wants to repeat it.
To repeat the test, follow the steps in #7 above.
Comment #9
damienmckennaComment #10
damienmckennaComment #11
damienmckennaHow do we re-trigger the tests when they never finished the first time?
Comment #12
dawehnerWell, the problem is testbot, see #2450447: Drupal QA is broken for Views 7.x-3.x and #2273481: Contrib PSR-4 PHPUnit tests are not picked up by PIFR
Comment #13
colanI was going to commit this one-liner, but maybe I should wait for #2450447: Drupal QA is broken for Views 7.x-3.x, if it's close?
Comment #14
dawehnerLet's just commit it ... Thank you for the patch!