Commit 7f273d25 authored by alexpott's avatar alexpott

Issue #2239307 by tim.plunkett: Remove obsolete _node_revision_access.

parent 2ccfe553
......@@ -96,14 +96,15 @@ function testNodeRevisionAccessAnyType() {
$permutations = $this->generatePermutations($parameters);
$node_revision_access = \Drupal::service('access_check.node.revision');
foreach ($permutations as $case) {
// Skip this test if there are no revisions for the node.
if (!($revision->isDefaultRevision() && (db_query('SELECT COUNT(vid) FROM {node_field_revision} WHERE nid = :nid', array(':nid' => $revision->id()))->fetchField() == 1 || $case['op'] == 'update' || $case['op'] == 'delete'))) {
if (!empty($case['account']->is_admin) || user_access($this->map[$case['op']], $case['account'])) {
$this->assertTrue(_node_revision_access($revision, $case['op'], $case['account']), "{$this->map[$case['op']]} granted.");
$this->assertTrue($node_revision_access->checkAccess($revision, $case['account'], $case['op']), "{$this->map[$case['op']]} granted.");
}
else {
$this->assertFalse(_node_revision_access($revision, $case['op'], $case['account']), "{$this->map[$case['op']]} not granted.");
$this->assertFalse($node_revision_access->checkAccess($revision, $case['account'], $case['op']), "{$this->map[$case['op']]} not granted.");
}
}
}
......@@ -111,7 +112,7 @@ function testNodeRevisionAccessAnyType() {
// Test that access is FALSE for a node administrator with an invalid $node
// or $op parameters.
$admin_account = $accounts['admin'];
$this->assertFalse(_node_revision_access($revision, 'invalid-op', $admin_account), '_node_revision_access() returns FALSE with an invalid op.');
$this->assertFalse($node_revision_access->checkAccess($revision, $admin_account, 'invalid-op'), 'NodeRevisionAccessCheck() returns FALSE with an invalid op.');
}
/**
......@@ -142,14 +143,15 @@ function testNodeRevisionAccessPerType() {
$revision = $this->node_revisions['page'][1];
$permutations = $this->generatePermutations($parameters);
$node_revision_access = \Drupal::service('access_check.node.revision');
foreach ($permutations as $case) {
// Skip this test if there are no revisions for the node.
if (!($revision->isDefaultRevision() && (db_query('SELECT COUNT(vid) FROM {node_field_revision} WHERE nid = :nid', array(':nid' => $revision->id()))->fetchField() == 1 || $case['op'] == 'update' || $case['op'] == 'delete'))) {
if (!empty($case['account']->is_admin) || user_access($this->type_map[$case['op']], $case['account'])) {
$this->assertTrue(_node_revision_access($revision, $case['op'], $case['account']), "{$this->type_map[$case['op']]} granted.");
$this->assertTrue($node_revision_access->checkAccess($revision, $case['account'], $case['op']), "{$this->type_map[$case['op']]} granted.");
}
else {
$this->assertFalse(_node_revision_access($revision, $case['op'], $case['account']), "{$this->type_map[$case['op']]} not granted.");
$this->assertFalse($node_revision_access->checkAccess($revision, $case['account'], $case['op']), "{$this->type_map[$case['op']]} not granted.");
}
}
}
......@@ -158,7 +160,7 @@ function testNodeRevisionAccessPerType() {
$revision = $this->node_revisions['article'][1];
foreach ($permutations as $case) {
$this->assertFalse(_node_revision_access($revision, $case['op'], $case['account']), "{$this->type_map[$case['op']]} did not grant revision permission for articles.");
$this->assertFalse($node_revision_access->checkAccess($revision, $case['account'], $case['op']), "{$this->type_map[$case['op']]} did not grant revision permission for articles.");
}
}
}
......@@ -898,34 +898,6 @@ function theme_node_search_admin($variables) {
return $output;
}
/**
* Access callback: Checks node revision access.
*
* @param \Drupal\node\NodeInterface $node
* The node to check.
* @param $op
* (optional) The specific operation being checked. Defaults to 'view.'
* @param object $account
* (optional) A user object representing the user for whom the operation is
* to be performed. Determines access for a user other than the current user.
* Defaults to NULL.
* @param $langcode
* (optional) Language code for the variant of the node. Different language
* variants might have different permissions associated. If NULL, the
* original langcode of the node is used. Defaults to NULL.
*
* @return
* TRUE if the operation may be performed, FALSE otherwise.
*
* @see node_menu()
*/
function _node_revision_access(NodeInterface $node, $op = 'view', $account = NULL, $langcode = NULL) {
if ($account === NULL) {
$account = \Drupal::currentUser();
}
return \Drupal::service('access_check.node.revision')->checkAccess($node, $account, $op, $langcode);
}
/**
* Title callback: Displays the node's title.
*
......
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