0

I have a view that displays results correctly for the admin user (uid = 1) but no result at all for the others and I can't figure out why:

  • The view's permission is set to "view published content" => not a permission problem;
  • The SQL queries are exactly the same for both users which means that the context is the same for both => not a building query problem;
  • For the admin user, the results are as expected, while for the others, it seems that the view does not display any result since the "no result message" appears for them.

The question is therefore: Why is this view displaying no result for other users than the admin when the context is the same, that it's not a permission-related issue and that the SQL queries are the same?

Thanks a lot!

EDIT:

The export of my views is the following:

$view = new view();
$view->name = 'clone_of_og_extras_group_admin';
$view->description = 'Délégués d\'un comité';
$view->tag = '';
$view->base_table = 'users';
$view->human_name = 'Liste délégué(s) d\'un comité';
$view->core = 0;
$view->api_version = '3.0';
$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['title'] = 'Délégué(s)';
$handler->display->display_options['use_more_always'] = TRUE;
$handler->display->display_options['access']['type'] = 'perm';
$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'] = 'none';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['style_plugin'] = 'responsive_grid';
$handler->display->display_options['style_options']['column_classes'] = 'userscol';
$handler->display->display_options['style_options']['row_classes'] = 'usersrow';
$handler->display->display_options['row_plugin'] = 'fields';
$handler->display->display_options['row_options']['inline'] = array(
  'picture' => 'picture',
  'name' => 'name',
);
/* Header: Global: Text area */
$handler->display->display_options['header']['area']['id'] = 'area';
$handler->display->display_options['header']['area']['table'] = 'views';
$handler->display->display_options['header']['area']['field'] = 'area';
$handler->display->display_options['header']['area']['content'] = '<h2 class="title">Délégué(s) du %1:</h2>';
$handler->display->display_options['header']['area']['format'] = 'php_code';
$handler->display->display_options['header']['area']['tokenize'] = TRUE;
/* No results behavior: Global: Text area */
$handler->display->display_options['empty']['area']['id'] = 'area';
$handler->display->display_options['empty']['area']['table'] = 'views';
$handler->display->display_options['empty']['area']['field'] = 'area';
$handler->display->display_options['empty']['area']['empty'] = TRUE;
$handler->display->display_options['empty']['area']['content'] = 'Il n\'y a pas de délégué attitré à ce comité. Si ce poste t\'intéresse, tu peux postuler en cliquant sur l\'onglet ci-dessous.';
$handler->display->display_options['empty']['area']['format'] = 'filtered_html';
/* Relationship: OG membership: OG membership from User */
$handler->display->display_options['relationships']['og_membership_rel']['id'] = 'og_membership_rel';
$handler->display->display_options['relationships']['og_membership_rel']['table'] = 'users';
$handler->display->display_options['relationships']['og_membership_rel']['field'] = 'og_membership_rel';
/* Relationship: User: Profile */
$handler->display->display_options['relationships']['profile']['id'] = 'profile';
$handler->display->display_options['relationships']['profile']['table'] = 'users';
$handler->display->display_options['relationships']['profile']['field'] = 'profile';
$handler->display->display_options['relationships']['profile']['required'] = TRUE;
$handler->display->display_options['relationships']['profile']['bundle_types'] = array(
  'main' => 'main',
);
/* Relationship: OG membership: Node from OG membership */
$handler->display->display_options['relationships']['og_membership_related_node']['id'] = 'og_membership_related_node';
$handler->display->display_options['relationships']['og_membership_related_node']['table'] = 'og_membership';
$handler->display->display_options['relationships']['og_membership_related_node']['field'] = 'og_membership_related_node';
$handler->display->display_options['relationships']['og_membership_related_node']['relationship'] = 'og_membership_rel';
/* Field: Profile: Photo de profil */
$handler->display->display_options['fields']['field_prof_pic_profile']['id'] = 'field_prof_pic_profile';
$handler->display->display_options['fields']['field_prof_pic_profile']['table'] = 'field_data_field_prof_pic_profile';
$handler->display->display_options['fields']['field_prof_pic_profile']['field'] = 'field_prof_pic_profile';
$handler->display->display_options['fields']['field_prof_pic_profile']['relationship'] = 'profile';
$handler->display->display_options['fields']['field_prof_pic_profile']['label'] = '';
$handler->display->display_options['fields']['field_prof_pic_profile']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['field_prof_pic_profile']['click_sort_column'] = 'fid';
$handler->display->display_options['fields']['field_prof_pic_profile']['settings'] = array(
  'image_style' => 'profile_picture',
  'image_link' => 'content',
);
/* 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']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['name']['element_wrapper_type'] = 'div';
/* Sort criterion: OG membership: Created */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'og_membership';
$handler->display->display_options['sorts']['created']['field'] = 'created';
$handler->display->display_options['sorts']['created']['relationship'] = 'og_membership_rel';
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
/* Contextual filter: OG membership: OG group gid */
$handler->display->display_options['arguments']['group']['id'] = 'group';
$handler->display->display_options['arguments']['group']['table'] = 'og_membership';
$handler->display->display_options['arguments']['group']['field'] = 'group';
$handler->display->display_options['arguments']['group']['relationship'] = 'og_membership_rel';
$handler->display->display_options['arguments']['group']['default_action'] = 'default';
$handler->display->display_options['arguments']['group']['default_argument_type'] = 'og_context';
$handler->display->display_options['arguments']['group']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['group']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['group']['summary_options']['items_per_page'] = '25';
/* 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';
/* Filter criterion: OG membership: State */
$handler->display->display_options['filters']['state']['id'] = 'state';
$handler->display->display_options['filters']['state']['table'] = 'og_membership';
$handler->display->display_options['filters']['state']['field'] = 'state';
$handler->display->display_options['filters']['state']['relationship'] = 'og_membership_rel';
$handler->display->display_options['filters']['state']['value'] = array(
  1 => '1',
);
/* Filter criterion: OG user roles: Role ID */
$handler->display->display_options['filters']['rid']['id'] = 'rid';
$handler->display->display_options['filters']['rid']['table'] = 'og_users_roles';
$handler->display->display_options['filters']['rid']['field'] = 'rid';
$handler->display->display_options['filters']['rid']['relationship'] = 'og_membership_rel';
$handler->display->display_options['filters']['rid']['value'] = array(
  3 => '3',
);
$handler->display->display_options['filters']['rid']['reduce_duplicates'] = TRUE;

/* Display: Entity Reference View Widget */
$handler = $view->new_display('entityreference_view_widget', 'Entity Reference View Widget', 'entityreference_view_widget_1');
$handler->display->display_options['defaults']['title'] = FALSE;
$handler->display->display_options['defaults']['exposed_form'] = FALSE;
$handler->display->display_options['exposed_form']['type'] = 'entityreference_view_widget';
$handler->display->display_options['defaults']['style_plugin'] = FALSE;
$handler->display->display_options['style_plugin'] = 'grid';
$handler->display->display_options['style_options']['columns'] = '3';
$handler->display->display_options['defaults']['style_options'] = FALSE;
$handler->display->display_options['defaults']['row_plugin'] = FALSE;
$handler->display->display_options['row_plugin'] = 'entity';
$handler->display->display_options['row_options']['view_mode'] = 'entityreference_view_widget';
$handler->display->display_options['defaults']['row_options'] = FALSE;

/* Display: EVA Field */
$handler = $view->new_display('entity_view', 'EVA Field', 'entity_view_1');
$handler->display->display_options['entity_type'] = 'node';
$handler->display->display_options['bundles'] = array(
  0 => 'comit_',
);
$handler->display->display_options['argument_mode'] = 'token';
$handler->display->display_options['default_argument'] = '[node:group:gid]';
$translatables['clone_of_og_extras_group_admin'] = array(
  t('Defaults'),
  t('Délégué(s)'),
  t('more'),
  t('Apply'),
  t('Reset'),
  t('Sort by'),
  t('Asc'),
  t('Desc'),
  t('<h2 class="title">Délégué(s) du %1:</h2>'),
  t('Il n\'y a pas de délégué attitré à ce comité. Si ce poste t\'intéresse, tu peux postuler en cliquant sur l\'onglet ci-dessous.'),
  t('OG membership from user'),
  t('Profile'),
  t('node from OG membership'),
  t('All'),
  t('Entity Reference View Widget'),
  t('EVA Field'),
);

It creates the following SQL query that returns two results (the same being displayed to the admin (uid=1) in my PHPMyAdmin. So as I said, the query is not the issue; it's when it comes to display the results.

SELECT profile_users.pid AS profile_users_pid, users.name AS users_name, users.uid AS uid, og_membership_users.created AS og_membership_users_created, 'profile2' AS field_data_field_prof_pic_profile_profile2_entity_type
FROM users users
INNER JOIN profile profile_users ON users.uid = profile_users.uid AND profile_users.type = 'main'
INNER JOIN og_membership og_membership_users ON users.uid = og_membership_users.etid AND og_membership_users.entity_type = 'user'
LEFT JOIN node node_og_membership ON og_membership_users.etid = node_og_membership.nid
LEFT JOIN og_users_roles og_users_roles_value_0 ON og_membership_users.gid = og_users_roles_value_0.gid AND og_users_roles_value_0.rid = 3
WHERE (( (og_users_roles_value_0.uid = users.uid) AND (og_membership_users.gid = 407 ) )AND(( (users.status <> 0) AND (og_membership_users.state IN (1)) AND( (og_users_roles_value_0.rid = 3) ))))
ORDER BY og_membership_users_created DESC
5
  • Export your view and paste it here; include also any details about your setup - which modules are you using, are there any custom ones, etc. And very important - try to replicate the same issue on a clean install. Commented Mar 16, 2014 at 15:02
  • If you are working on development site then assign administrator role to a specific user and check your view result. If result are same as previous then some problem with your views otherwise problem in permission.
    – Rupesh
    Commented Mar 16, 2014 at 16:33
  • I assume the nodes in the results are actually published and you are not using any access control modules? The view permission being set to "view published content" only controls access to the view, it has nothing to do with which results show up, that relates to views filters and contextual filters. One of those could be the problem but you will need to tell us your views filters and contextual filters for us to know.
    – rooby
    Commented Mar 16, 2014 at 16:46
  • @Topsitemakers I have set the export of the view in the question. I can hardly replicate the issue on a clean install as it depends on many things (mostly OG and complex user relationships...);
    – jozi
    Commented Mar 16, 2014 at 16:55
  • @rooby: The view displays users, not node -- and users have access to other users' page so it's not a permission problem. About the filters, you can have a more detailed overview thanks to the edit of my question including its export. As you can see, I have one contextual filter depending on the Group ID (GID) of the Organic Group being seen. The view is supposed to show the users having a certain OG role in the group.
    – jozi
    Commented Mar 16, 2014 at 17:06

1 Answer 1

1

I found out after hours it was eventually a permission issue; for some reason, only the user with UID = 1 can have access to this view being displayed and it seems to be a known issue (cf. Stella's article where you can find the hack she proposes).

In my case, I bypassed the access by giving temporary access to user 1 permission when outputting the view (through EVA). (cf. this comment on the same article) Even though I don't really like this solution since it doesn't seem very secure, I think the risk is minim since I remove any "power user" access right after having executed the view.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.