I used a views php validation for a contextual filter:
"Content: NID" > "Provide default value" > "Content ID from URL" > "Validation Criteria" > PHP

$node = menu_get_object();
if (isset($node->field_quiz)) {
  $quiz_nid = $node->field_quiz['und'][0]['target_id'];
  $quiz_node = node_load($quiz_nid); 
  return quiz_take_access($quiz_node); 
}
return false;

This was set in the master, but I was over-riding it on all views displays but one. When I tried to remove it to test if this was the issue described below, it was not seen in any of the displays, but was still in the master, and in cache. I removed it from the master, but it was still present in the view, in cache, and still in there when exporting the view.

Using:
Drupal 7.35
Views 7.x-3.10
Panels 7.x-3.5
Ctools 7.x-1.7
Views php 7.x-1.0-alpha1

Originally titled "Views content pane not showing in panel for some users", as that was the symptom. The original symptom I was experience is as follows:

I have a view content pane displaying a node of a certain content type. This content type contains entity reference fields which are rendered as nodes on in the view field settings. On this view, I have a contextual filter of type "Content: NID" with "Provide default value" selected and "Content ID from URL" selected in the drop-down.

I created a panel page over-riding the node template, and a variant with 2 selection rules: 1) Node being viewed is this content type, and 2) "Node: accessible - Logged in user can view Node being viewed."

I am using two users to test - the admin user, and a test user.

  1. When I view this panel page as an admin, with 'bypass node access' permission, I can see the panel with the content pane, and the node and the referenced nodes that are present in the view.
  2. In the node access table, the node is listed with the correct realm and gid.
  3. Debugging output shows that my test user has the correct grants (at least one grant contains realm and gid that matches the node_access records), and should be able to view the node.
  4. If I disable the panel, my test user CAN access the node directly, as well as the nodes referenced in the entity reference fields.
  5. I made a copy of the content pane display (as a view page, with url), and my test user CAN access the view, and all nodes on the view.
  6. When my test user tries to view the panel page, he sees the OTHER panes on the panel (which I assume tells me that "logged in user can view node being viewed" is TRUE, as the variant IS being displayed).
  7. One strange thing that I noticed, is that when I try to preview the content pane display by manually adding the NID argument, I get nothing - no query being displayed, and no content being rendered, but this is for the content pane, not the view page display with url. Adding the NID argument on the page display presents the preview correctly.

The test user can NOT see the views content pane embedded in the panel, while the admin user can. The pane simply does not render, and the "No results behaviour" of the view, which is set to display a message, does not render, either. It is just blank.

Anyone know why the content pane would not render? Is there some permission that I'm missing, or some setting on the views content pane screen? Or some setting on the panel variant configuration, or the pane configuration? I don't see anything that should hide this pane, and I don't understand why it isn't being rendered.

Comments

joshua.albert’s picture

So far I've traced it down to line 287 in sites/all/modules/ctools/views_content/plugins/content_types/views_panes.inc:

$block->content = $view->preview();

Debugging output before this line shows that the $view object is identical to both users. Debugging output after this line shows that the preview() function is rendering correctly for admin and returning blank for the test user.

Looking into preview() function now...

joshua.albert’s picture

I believe I found the issue.

At one point, in one of my view displays, I used the following PHP code as a validation option:

$node = menu_get_object();
if (isset($node->field_quiz)) {
  $quiz_nid = $node->field_quiz['und'][0]['target_id'];
  $quiz_node = node_load($quiz_nid); 
  return quiz_take_access($quiz_node); 
}
return false;

This is one of the node reference fields (a quiz). Here, I load the quiz based on the entity reference field, and then run quiz_take_access to see if the user has access to the quiz. If not, the validator returns false, and the view isn't rendered.

However, I have removed this from the view, so I didn't think that this should be an issue. Unfortunately, when outputting some debugging code, I found that this validation option WAS present in the cached view:

// This still had the old PHP code that should not longer be in the view
$this->display_handler->handlers['argument']['nid']['options']['validate_options']['code'];

joshua.albert’s picture

Title: Views content pane not showing in panel for some users » PHP Validation options remain in view even after being removed via the views ui.
Project: Chaos Tool Suite (ctools) » Views PHP
Version: 7.x-1.7 » 7.x-1.0-alpha1
Component: Miscellaneous » Code
Category: Support request » Bug report

OK, so it appears that the issue was that this validation code was still in the view even when it was removed via the views UI.

In order to fix it, I exported the view, manually deleted the validation option, and re-imported the view (with "replace existing view if the same name" checked).

This fixed the issue, but it does bring up a bug. Not sure if this bug is with ctools, views, or views_php, however. My guess is views php, since that is what I used for the validation options.

Changing the title of this issue to reflect what is really going on, editing the original issue description, changing the project to views_php, and changing the category to "bug report".

joshua.albert’s picture

Issue summary: View changes
joshua.albert’s picture

Issue summary: View changes