Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have a views, it contain three different displays:
display_id | access php code | overridden access control |
default |
return true; |
No |
block_1 |
return true; |
No |
block_2 |
return false; |
Yes |
And both block_1, and block_2 are enabled in the current theme.
block_1 | block_2 | |
Expectation | visible | invisible |
Observation | visible | visible ?? |
Reason:
I checked the access function in views_php_plugin_access.inc:
function access($account) {
if (!empty($this->options['php_access'])) {
print_r($this->view->name);
print_r('<br>');
print_r($this->view->current_display);
print_r('<br>');
return views_php_check_access($this->options['php_access'], $this->view->name, $this->view->current_display, $account);
}
return TRUE;
}
And found out that, no matter for which display( block_1, block_2), $this->view->current_display == 'default'
, which means that:
the php access plugin will always use the php code for default display to determine the accessibility of any other displays, even if the display has overridde php access code.
Comments
Comment #1
foredoc CreditAttribution: foredoc commentedCould this be a bug of views?
Because I also checked the views_plugin_access_role.inc, it has the same problem:
Always tend to the access setting of the default display.
Thanks.
Comment #2
foredoc CreditAttribution: foredoc commentedAnyone has similar problem?
Thanks.
Comment #3
Liam MorlandDrupal 6 is no longer supported. If this applies to a later version, please re-open and update the version.