Since field_view_field returns a renderable array with #access to false if user doesn't have access via field_access, it doesn't treat the pane as empty and instead renders the pane but with no content.

CommentFileSizeAuthor
ctoos_entity_field_access.patch591 byteshefox
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Status: Needs review » Needs work

The last submitted patch, ctoos_entity_field_access.patch, failed testing.

hefox’s picture

Status: Needs work » Needs review

RoSk0’s picture

Category: Feature request » Bug report
Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

I would say that it is a bug.
Tested patch on both latest stable release and HEAD.
Works as expected.

japerry’s picture

Status: Reviewed & tested by the community » Needs review

This doesn't look right. What if #access was set to TRUE?

RoSk0’s picture

Status: Needs review » Reviewed & tested by the community

I'm still sure this is RTBC because $field_output is produced by field_view_field() which is, from function documentation:

The function takes care of invoking the prepare_view steps. It also respects field access permissions.
rivimey’s picture

Status: Reviewed & tested by the community » Needs review

I'm with japerry on this. Surely

  $block->content = !empty($field_output['#access']) ? $field_output : NULL;

should be:

  // if there isn't an #access element, or there is and it's TRUE...
  $accessible = empty($field_output['#access']) || (!empty($field_output['#access']) && $field_output['#access']);
  $block->content = $accessible ? $field_output : '';

[changed NULL because we're supposed to return a string, surely!]