Commit 7daedb3e authored by catch's avatar catch

Issue #2659078 by dpi: Unexpected access operation throws exception when node...

Issue #2659078 by dpi: Unexpected access operation throws exception when node grant system is active
parent 376180d3
......@@ -65,6 +65,11 @@ public function __construct(Connection $database, ModuleHandlerInterface $module
* {@inheritdoc}
*/
public function access(NodeInterface $node, $operation, AccountInterface $account) {
// Grants only support these operations.
if (!in_array($operation, ['view', 'update', 'delete'])) {
return AccessResult::neutral();
}
// If no module implements the hook or the node does not have an id there is
// no point in querying the database for access grants.
if (!$this->moduleHandler->getImplementations('node_grants') || !$node->id()) {
......
......@@ -26,4 +26,13 @@ class NodeAccessGrantsTest extends NodeAccessTest {
*/
public static $modules = array('node_access_test_empty');
/**
* Test operations not supported by node grants.
*/
function testUnsupportedOperation() {
$web_user = $this->drupalCreateUser(['access content']);
$node = $this->drupalCreateNode();
$this->assertNodeAccess(['random_operation' => FALSE], $node, $web_user);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment