Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
There seem to be a number of ways to create a view that generates PHP notices like the following every time you view it:
Notice: Undefined index: uid in views_handler->get_value() (line 264 of /home/droth/web/drupal/sites/all/modules/views/includes/handlers.inc).
One example that does this is the view pasted below (this is a basic view of users configured to use a jump menu with the "uid" field rewritten to user/[uid]
so the jump menu can use it as the path). I'm still working on figuring out exactly what causes it, although I might have an idea.
$view = new view;
$view->name = 'jumpmenu';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'users';
$view->human_name = 'jumpmenu';
$view->core = 7;
$view->api_version = '3.0-alpha1';
$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'] = 'jumpmenu';
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['access']['perm'] = 'access user profiles';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$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'] = 'jump_menu';
$handler->display->display_options['style_options']['hide'] = 0;
$handler->display->display_options['style_options']['path'] = 'uid';
$handler->display->display_options['style_options']['default_value'] = 0;
$handler->display->display_options['row_plugin'] = 'fields';
/* Field: User: Name */
$handler->display->display_options['fields']['name']['id'] = 'name';
$handler->display->display_options['fields']['name']['table'] = 'users';
$handler->display->display_options['fields']['name']['field'] = 'name';
$handler->display->display_options['fields']['name']['label'] = '';
$handler->display->display_options['fields']['name']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['name']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['name']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['name']['alter']['trim'] = 0;
$handler->display->display_options['fields']['name']['alter']['word_boundary'] = 0;
$handler->display->display_options['fields']['name']['alter']['ellipsis'] = 0;
$handler->display->display_options['fields']['name']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['name']['alter']['html'] = 0;
$handler->display->display_options['fields']['name']['hide_empty'] = 0;
$handler->display->display_options['fields']['name']['empty_zero'] = 0;
$handler->display->display_options['fields']['name']['link_to_user'] = 1;
$handler->display->display_options['fields']['name']['overwrite_anonymous'] = 0;
/* Field: User: Uid */
$handler->display->display_options['fields']['uid']['id'] = 'uid';
$handler->display->display_options['fields']['uid']['table'] = 'users';
$handler->display->display_options['fields']['uid']['field'] = 'uid';
$handler->display->display_options['fields']['uid']['exclude'] = TRUE;
$handler->display->display_options['fields']['uid']['alter']['alter_text'] = 1;
$handler->display->display_options['fields']['uid']['alter']['text'] = 'user/[uid]';
$handler->display->display_options['fields']['uid']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['uid']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['uid']['alter']['external'] = 0;
$handler->display->display_options['fields']['uid']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['uid']['alter']['trim'] = 0;
$handler->display->display_options['fields']['uid']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['uid']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['uid']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['uid']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['uid']['alter']['html'] = 0;
$handler->display->display_options['fields']['uid']['element_label_colon'] = 1;
$handler->display->display_options['fields']['uid']['element_default_classes'] = 1;
$handler->display->display_options['fields']['uid']['hide_empty'] = 0;
$handler->display->display_options['fields']['uid']['empty_zero'] = 0;
$handler->display->display_options['fields']['uid']['link_to_user'] = 0;
/* Sort criterion: User: Created date */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'users';
$handler->display->display_options['sorts']['created']['field'] = 'created';
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
/* Filter criterion: User: Active */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'users';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = '1';
$handler->display->display_options['filters']['status']['group'] = 0;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'jumpmenu';
$translatables['jumpmenu'] = array(
t('Master'),
t('jumpmenu'),
t('more'),
t('Apply'),
t('Reset'),
t('Sort by'),
t('Asc'),
t('Desc'),
t('Items per page'),
t('- All -'),
t('Offset'),
t('Uid'),
t('user/[uid]'),
t('Page'),
);
Comment | File | Size | Author |
---|---|---|---|
#17 | views-n1103234-16.patch | 550 bytes | AexChecker |
Comments
Comment #1
bojanz CreditAttribution: bojanz commentedThe cause of this is code trying to access a value (such as 'uid') that hasn't been added to the query.
$value = $this->get_value($values, 'uid');
get_value() searches for 'uid' among aliases, the aliases array doesn't have such a key, a notice gets thrown.
Notices like that could easily be silenced (an isset), but it's always a symptom of a bigger problem (you aren't getting the data you need), so it's actually useful.
Comment #2
dawehnerHere is a specific fix for this field.
@bojanz
You planned to be offline for tonight :)
Comment #3
David_Rothstein CreditAttribution: David_Rothstein commentedRight, but 'uid' is part of the query, so the question is why it doesn't appear.
I eventually figured it out - this seems to often be caused by cases where the conditions in handler init() methods don't match the conditions in render_link(). This patch fixes the two cases I know about.
Comment #4
David_Rothstein CreditAttribution: David_Rothstein commentedWow, nice crosspost there :)
I think we need to use my code though - @dereine's won't work because it checks $uid in the if() condition before it's defined, i.e.:
And as mentioned, I fixed a similar case for node revisions too.
Comment #5
dawehnerOh Thanks you are right!
Commited it to 6.x-3.x and 7.x-3.x. People will find, if there are remaining issues.
Comment #7
luigithekid CreditAttribution: luigithekid commentedSorry to reopen this issue, but I have a user view with the language field showing (I have English and Spanish installed) and was getting these notices. This was with the latest views (patch above applied). As soon as I removed the language field, the Notices went away. Just letting you know if you want to replicate it and fix it.
Comment #8
dawehnerUpdate status. Needs review means that there is a patch availible.
Comment #9
dawehnerCan you export the view so it's easy to know which field you actually talking about? Thanks!
Comment #10
dawehnerUpdate status
Comment #11
esmerel CreditAttribution: esmerel commentedComment #12
Håvard CreditAttribution: Håvard commentedI get this error with Open Atrium 7.x-2.4 distro on Pantheon.
Notice: Undefined index: group in views_handler->ui_name() (line 277 of /.../profiles/openatrium/modules/contrib/views/includes/handlers.inc).
Comment #13
yasmrf CreditAttribution: yasmrf commentedI just installed OpenAtrium 2.33 (7.x) on a new server (Windows Server 2012 R2 - Apache 2.4 - MySQL 5.6 - PHP 5.6). I had the exact same problem at the end of the installation and later on :
"Notice: Undefined index: group in views_handler->ui_name() (line 277 of ...\profiles\openatrium\modules\contrib\views\includes\handlers.inc)".
Also, when I want to create a new space from the home page, I get this pop-up error message :
"An AJAX HTTP error occurred.
HTTP Result Code: 404
Debugging information follows.
Path: /api/oa_wizard/space-wizard?sitemap=1
StatusText: Not Found
ResponseText:
404 Not Found
Not Found
The requested URL /api/oa_wizard/space-wizard was not found on this server"
I need your help please !!!
Comment #14
WJNLLC CreditAttribution: WJNLLC commentedNotice: Undefined index: group in views_handler->ui_name() (line 277 of ../sites/all/modules/views/includes/handlers.inc).
Comment #15
WJNLLC CreditAttribution: WJNLLC commentedNotice: Undefined index: group in views_handler->ui_name() (line 277 of ../sites/all/modules/views/includes/handlers.inc).
Comment #16
mmilutinovic1313 CreditAttribution: mmilutinovic1313 commentedHi all --
I have run into this error as well and was wondering the current status on fixing this issue.
The function in question that contains the line that is giving us all trouble is the
ui_name
function. I am posting the source below as an easy reference point to get this discussion flowing again:The return statement is line 277. I am going to start looking for solutions too, but feel free to continue the discussion below.
Thanks!
mmilutinovic1313
Comment #17
AexChecker CreditAttribution: AexChecker as a volunteer commentedMaybe, this patch helps.
Comment #18
erpmacher CreditAttribution: erpmacher commented@AexChecker
Fine, this works within the distribution ERPAL Platform 7.x-3.0-beta2.
File: profiles/erpal_platform/modules/contrib/views/includes/handlers.inc
Drupal 7.41
Postgres 9
Thx;-)
Comment #19
MustangGB CreditAttribution: MustangGB commentedComment #20
helmo CreditAttribution: helmo as a volunteer and at Initfour websolutions for Aegir Cooperative commented#17 helped for me.
Comment #23
helmo CreditAttribution: helmo as a volunteer and at Initfour websolutions for Aegir Cooperative commentedI've hidden the old patches.
Comment #24
DamienMcKennaComment #25
DamienMcKennaCommitted. Thanks.