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'),
);
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bojanz’s picture

The 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.

dawehner’s picture

Version: 7.x-3.x-dev » 6.x-3.x-dev
Status: Active » Needs review
FileSize
861 bytes

Here is a specific fix for this field.

@bojanz
You planned to be offline for tonight :)

David_Rothstein’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev
FileSize
1.72 KB

Right, 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.

David_Rothstein’s picture

Wow, 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.:

-    $uid = $this->get_value($values, 'uid');
     if (!empty($this->options['link_to_user']) && user_access('access user profiles') && $uid && $data !== NULL && $data !== '') {

And as mentioned, I fixed a similar case for node revisions too.

dawehner’s picture

Status: Needs review » Fixed

Oh Thanks you are right!

Commited it to 6.x-3.x and 7.x-3.x. People will find, if there are remaining issues.

Status: Fixed » Closed (fixed)

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

luigithekid’s picture

Status: Closed (fixed) » Needs review

Sorry 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.

dawehner’s picture

Status: Needs review » Active

Update status. Needs review means that there is a patch availible.

dawehner’s picture

Can you export the view so it's easy to know which field you actually talking about? Thanks!

dawehner’s picture

Status: Active » Postponed (maintainer needs more info)

Update status

esmerel’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)
Håvard’s picture

I 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).

yasmrf’s picture

Component: Code » Views Data
Category: Bug report » Support request
Priority: Normal » Critical
Status: Closed (cannot reproduce) » Active

I 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 !!!

WJNLLC’s picture

Notice: Undefined index: group in views_handler->ui_name() (line 277 of ../sites/all/modules/views/includes/handlers.inc).

WJNLLC’s picture

Title: PHP notice: Undefined index in in views_handler->get_value() for several kinds of views » Notice: Undefined index: group in views_handler->ui_name() (line 277 of ../sites/all/modules/views/includes/handlers.inc).
Issue tags: +group, +views, +handler

Notice: Undefined index: group in views_handler->ui_name() (line 277 of ../sites/all/modules/views/includes/handlers.inc).

mmilutinovic1313’s picture

Hi 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:

function ui_name($short = FALSE) {
    if (!empty($this->options['ui_name'])) {
      $title = check_plain($this->options['ui_name']);
      return $title;
    }
    $title = ($short && isset($this->definition['title short'])) ? $this->definition['title short'] : $this->definition['title'];
    return t('!group: !title', array('!group' => $this->definition['group'], '!title' => $title));
  }

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

AexChecker’s picture

erpmacher’s picture

@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;-)

MustangGB’s picture

Priority: Critical » Normal
Issue tags: -group, -views, -handler
helmo’s picture

Status: Active » Reviewed & tested by the community

#17 helped for me.

The last submitted patch, 2: 1103234-field_user_link-notice.patch, failed testing. View results

The last submitted patch, 3: views-php-notice-get-value-1103234-2.patch, failed testing. View results

helmo’s picture

DamienMcKenna’s picture

Category: Support request » Bug report
DamienMcKenna’s picture

Status: Reviewed & tested by the community » Fixed
Parent issue: » #2960871: Plan for Views 7.x-3.23 release

Committed. Thanks.

  • DamienMcKenna committed 0f6e47b on 7.x-3.x
    Issue #1103234 by dawehner, David_Rothstein, AexChecker, helmo, bojanz,...

Status: Fixed » Closed (fixed)

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