Hi,
I made a new view using the type "user". I added fields, filtering, classification criteria and the query/result was ok, as expected.
When I tried to insert an argument the problems started. I found 2 errors / bugs.

1 - I tried to put as argument "User: Authentication_name" to get the command line as: www.com/abc/username .

1.1 - without validation, the only way to get a result was using the argument ALL, which obviously returned all records.

1.2 - with validation for user, I realized that the module validates properly but when building the query it changes the argument for the UserID, making a null response with " Where (...) authmap.authname = '2' " (where 2 is the userID) . When I try to put an invalid argument, the module responds correctly. If I put ALL it also responds correctly with all data.

2 - I changed the argument to "User: UID."

2.1 without validation, the module worked correctly, returning null if the argument was invalid and returning the correct data when the UID was a valid one.

2.2 using the validation by the user, allowing only numbers, the module worked correctly as above.

2.3 using the validation by the user, allowing only the name, the module worked correctly when the URL is asked by an authenticated user. For anonymous users the module returns the result plus the following error:

Notice: Undefined property: stdClass::$name in views_plugin_argument_validate_user->validate_argument() (line 85 on /home/public_html/sites/all/modules/views/modules/user/views_plugin_argument_validate_user.inc).

I hope that this long explanation helps you understand where I found the problems.

RedBeard

Comments

EdBiancarelli’s picture

Title: Error whith argument validation » Error with argument validation
dawehner’s picture

Status: Active » Needs review
StatusFileSize
new1.8 KB

A bit better would be if you provide an export of the view.
Then it's just some clicks and it's reproduced.

Does this patch fixes the issue for you?

EdBiancarelli’s picture

Sorry... this path didn't fixed.

This code below shows the 3 errors in my initial message. It is only one view with 3 diferent pages using diferent arguments.

Error 1.1 - you can try insert any value in arguments field, no results. Only using ALL .

Error 1.2 - when you put a valid argument (a user name), the query builded by Views show " authmap.authname = '2' " in WHERE line. I think the validation function changes the username to userID.

Error 2.3 - when you use this view in a authenticated user, all works fine. When the user is Anonymous, the system works but shows the error message twice when the argument is valid, and one time when the argument is invalid (showing the page-not-found message too)

Thanks for your help.

$view = new view;
$view->name = 'consult_com_erro_2';
$view->description = '';
$view->tag = '';
$view->base_table = 'users';
$view->human_name = 'Consult with error';
$view->core = 7;
$view->api_version = '3.0-alpha1';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Defaults */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->display->display_options['access']['type'] = 'none';
$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['exposed_form']['options']['reset_button_label'] = 'Restaurar';
$handler->display->display_options['pager']['type'] = 'none';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'fields';
/* Campo: Usuário: Nome */
$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']['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']['external'] = 0;
$handler->display->display_options['fields']['name']['alter']['trim'] = 0;
$handler->display->display_options['fields']['name']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['name']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['name']['alter']['ellipsis'] = 1;
$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']['element_label_type'] = '0';
$handler->display->display_options['fields']['name']['element_label_colon'] = 1;
$handler->display->display_options['fields']['name']['element_default_classes'] = 1;
$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;
/* Campo: Fields: field_fullname */
$handler->display->display_options['fields']['entity_id']['id'] = 'entity_id';
$handler->display->display_options['fields']['entity_id']['table'] = 'field_data_field_fullname';
$handler->display->display_options['fields']['entity_id']['field'] = 'entity_id';
$handler->display->display_options['fields']['entity_id']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['entity_id']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['entity_id']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['entity_id']['alter']['external'] = 0;
$handler->display->display_options['fields']['entity_id']['alter']['trim'] = 0;
$handler->display->display_options['fields']['entity_id']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['entity_id']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['entity_id']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['entity_id']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['entity_id']['alter']['html'] = 0;
$handler->display->display_options['fields']['entity_id']['element_label_type'] = '0';
$handler->display->display_options['fields']['entity_id']['element_label_colon'] = 1;
$handler->display->display_options['fields']['entity_id']['element_default_classes'] = 1;
$handler->display->display_options['fields']['entity_id']['hide_empty'] = 0;
$handler->display->display_options['fields']['entity_id']['empty_zero'] = 0;
$handler->display->display_options['fields']['entity_id']['field_api_classes'] = 0;
/* Sort criterion: Fields: field_fullname (field_fullname) - value */
$handler->display->display_options['sorts']['field_fullname_value']['id'] = 'field_fullname_value';
$handler->display->display_options['sorts']['field_fullname_value']['table'] = 'field_data_field_fullname';
$handler->display->display_options['sorts']['field_fullname_value']['field'] = 'field_fullname_value';
/* Filtrar: Usuário: Ativo */
$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';
/* Filtrar: Usuário: Papéis */
$handler->display->display_options['filters']['rid']['id'] = 'rid';
$handler->display->display_options['filters']['rid']['table'] = 'users_roles';
$handler->display->display_options['filters']['rid']['field'] = 'rid';
$handler->display->display_options['filters']['rid']['value'] = array(
  4 => '4',
);
$handler->display->display_options['filters']['rid']['reduce_duplicates'] = 0;

/* Display: Error 1.1 */
$handler = $view->new_display('page', 'Error 1.1', 'error_1_1');
$handler->display->display_options['defaults']['arguments'] = FALSE;
/* Argument: Usuário: Authentication name */
$handler->display->display_options['arguments']['authname']['id'] = 'authname';
$handler->display->display_options['arguments']['authname']['table'] = 'authmap';
$handler->display->display_options['arguments']['authname']['field'] = 'authname';
$handler->display->display_options['arguments']['authname']['default_action'] = 'not found';
$handler->display->display_options['arguments']['authname']['style_plugin'] = 'default_summary';
$handler->display->display_options['arguments']['authname']['default_argument_type'] = 'fixed';
$handler->display->display_options['arguments']['authname']['glossary'] = 0;
$handler->display->display_options['arguments']['authname']['limit'] = '0';
$handler->display->display_options['arguments']['authname']['transform_dash'] = 0;
$handler->display->display_options['arguments']['authname']['break_phrase'] = 0;
$handler->display->display_options['path'] = 'test1/%';

/* Display: Error 1.2 */
$handler = $view->new_display('page', 'Error 1.2', 'error_1_2');
$handler->display->display_options['defaults']['arguments'] = FALSE;
/* Argument: Usuário: Authentication name */
$handler->display->display_options['arguments']['authname']['id'] = 'authname';
$handler->display->display_options['arguments']['authname']['table'] = 'authmap';
$handler->display->display_options['arguments']['authname']['field'] = 'authname';
$handler->display->display_options['arguments']['authname']['default_action'] = 'not found';
$handler->display->display_options['arguments']['authname']['style_plugin'] = 'default_summary';
$handler->display->display_options['arguments']['authname']['default_argument_type'] = 'fixed';
$handler->display->display_options['arguments']['authname']['validate_type'] = 'user';
$handler->display->display_options['arguments']['authname']['validate_options']['type'] = 'name';
$handler->display->display_options['arguments']['authname']['validate_options']['restrict_roles'] = '1';
$handler->display->display_options['arguments']['authname']['validate_options']['roles'] = array(
  4 => '4',
);
$handler->display->display_options['arguments']['authname']['glossary'] = 0;
$handler->display->display_options['arguments']['authname']['limit'] = '0';
$handler->display->display_options['arguments']['authname']['transform_dash'] = 0;
$handler->display->display_options['arguments']['authname']['break_phrase'] = 0;
$handler->display->display_options['path'] = 'test2/%';

/* Display: Error 2.3 */
$handler = $view->new_display('page', 'Error 2.3', 'error_2_3');
$handler->display->display_options['defaults']['arguments'] = FALSE;
/* Argument: Usuário: Uid */
$handler->display->display_options['arguments']['uid']['id'] = 'uid';
$handler->display->display_options['arguments']['uid']['table'] = 'users';
$handler->display->display_options['arguments']['uid']['field'] = 'uid';
$handler->display->display_options['arguments']['uid']['default_action'] = 'not found';
$handler->display->display_options['arguments']['uid']['style_plugin'] = 'default_summary';
$handler->display->display_options['arguments']['uid']['default_argument_type'] = 'fixed';
$handler->display->display_options['arguments']['uid']['validate_type'] = 'user';
$handler->display->display_options['arguments']['uid']['validate_options']['type'] = 'name';
$handler->display->display_options['arguments']['uid']['validate_options']['restrict_roles'] = '1';
$handler->display->display_options['arguments']['uid']['validate_options']['roles'] = array(
  4 => '4',
);
$handler->display->display_options['arguments']['uid']['break_phrase'] = 0;
$handler->display->display_options['arguments']['uid']['not'] = 0;
$handler->display->display_options['path'] = 'test3/%';
$translatables['consult_com_erro_2'] = array(
  t('Defaults'),
  t('more'),
  t('Apply'),
  t('Restaurar'),
  t('Sort By'),
  t('Asc'),
  t('Desc'),
  t('Nome'),
  t('field_fullname'),
  t('Error 1.1'),
  t('Tudo'),
  t('Error 1.2'),
  t('Error 2.3'),
);
EdBiancarelli’s picture

Status: Needs review » Active

Sorry... I did forgot to change status.

dawehner’s picture

Status: Active » Needs work

So

sw3b’s picture

Same thing for me when anonymous user see some view. The patch #2 is not working.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new738 bytes

Does this patch work for you?

czigor’s picture

This patch solves 2.2 from #0 for me.

In my clean install problems 1.1 and 1.2 only appeared in the Preview of the view. If I accessed the view via its path (www.com/abc/username) it worked well.

Views and ctools are most up-to-date devs.

karilu_ec’s picture

The Patch in #7 fixed the error I was also getting when the anonymous user was viewing the page with the path
www.com/abc/username. I was only getting the error when the an anonymous user was accesing that page with authenticated users it was working fine.

dawehner’s picture

Status: Needs review » Fixed

Thanks for testing the patch.

Commited to 7.x-3.x

Status: Fixed » Closed (fixed)

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