Issue #3261251 by ravi.shankar, andypost, longwave, daffie: Remove deprecated node module functions

merge-requests/1727/head
catch 2022-02-09 09:52:23 +00:00
parent b5942f0c73
commit 0c65c0592c
18 changed files with 4 additions and 788 deletions

View File

@ -476,10 +476,6 @@ function drupal_static_reset($name = NULL) {
@trigger_error("Calling drupal_static_reset() with 'taxonomy_vocabulary_get_names' as argument is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. There is no replacement for this usage. See https://www.drupal.org/node/3039041", E_USER_DEPRECATED);
break;
case 'node_mark':
@trigger_error("Calling drupal_static_reset() with 'node_mark' as argument is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. There is no replacement for this usage. See https://www.drupal.org/node/3037203", E_USER_DEPRECATED);
break;
case 'Drupal\book\BookManager::bookSubtreeData':
case 'Drupal\book\BookManager::bookTreeAllData':
case 'Drupal\book\BookManager::doBookTreeBuild':

View File

@ -89,12 +89,3 @@ block.settings.node_syndicate_block:
block_count:
type: integer
label: 'Block count'
condition.plugin.node_type:
deprecated: "The 'condition.plugin.node_type' config schema is deprecated in drupal:9.3.0 and is removed from drupal 10.0.0. Use the 'entity_bundle:node_type' key instead to define a node type condition. See https://www.drupal.org/node/2983299."
type: condition.plugin
mapping:
bundles:
type: sequence
sequence:
type: string

View File

@ -8,18 +8,6 @@ services:
arguments: ['@database', '@module_handler', '@language_manager']
tags:
- { name: backend_overridable }
access_check.node.revision:
class: Drupal\node\Access\NodeRevisionAccessCheck
arguments: ['@entity_type.manager']
tags:
- { name: access_check, applies_to: _access_node_revision }
deprecated: The "%service_id%" service is deprecated. You should use the 'access_check.entity' service instead. See https://www.drupal.org/node/3161210
access_check.node.add:
class: Drupal\node\Access\NodeAddAccessCheck
arguments: ['@entity_type.manager']
deprecated: The "%service_id%" service is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use _entity_create_access or _entity_create_any_access access checks instead. See https://www.drupal.org/node/2836069
tags:
- { name: access_check, applies_to: _node_add_access }
access_check.node.preview:
class: Drupal\node\Access\NodePreviewAccessCheck
arguments: ['@entity_type.manager']

View File

@ -1,72 +0,0 @@
<?php
namespace Drupal\node\Access;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Routing\Access\AccessInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\node\NodeTypeInterface;
/**
* Determines access to for node add pages.
*
* @ingroup node_access
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
* _entity_create_access or _entity_create_any_access access checks instead.
*
* @see https://www.drupal.org/node/2836069
*/
class NodeAddAccessCheck implements AccessInterface {
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* Constructs an EntityCreateAccessCheck object.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
$this->entityTypeManager = $entity_type_manager;
}
/**
* Checks access to the node add page for the node type.
*
* @param \Drupal\Core\Session\AccountInterface $account
* The currently logged in account.
* @param \Drupal\node\NodeTypeInterface $node_type
* (optional) The node type. If not specified, access is allowed if there
* exists at least one node type for which the user may create a node.
*
* @return \Drupal\Core\Access\AccessResultInterface
* The access result.
*/
public function access(AccountInterface $account, NodeTypeInterface $node_type = NULL) {
$access_control_handler = $this->entityTypeManager->getAccessControlHandler('node');
// If checking whether a node of a particular type may be created.
if ($account->hasPermission('administer content types')) {
return AccessResult::allowed()->cachePerPermissions();
}
if ($node_type) {
return $access_control_handler->createAccess($node_type->id(), $account, [], TRUE);
}
// If checking whether a node of any type may be created.
foreach ($this->entityTypeManager->getStorage('node_type')->loadMultiple() as $node_type) {
if (($access = $access_control_handler->createAccess($node_type->id(), $account, [], TRUE)) && $access->isAllowed()) {
return $access;
}
}
// No opinion.
return AccessResult::neutral();
}
}

View File

@ -1,92 +0,0 @@
<?php
namespace Drupal\node\Access;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Routing\Access\AccessInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\node\NodeInterface;
use Symfony\Component\Routing\Route;
/**
* Provides an access checker for node revisions.
*
* @ingroup node_access
*/
class NodeRevisionAccessCheck implements AccessInterface {
/**
* The node storage.
*
* @var \Drupal\node\NodeStorageInterface
*/
protected $nodeStorage;
/**
* Constructs a new NodeRevisionAccessCheck.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
@trigger_error('NodeRevisionAccessCheck is deprecated in drupal:9.3.0 and will be removed before drupal:10.0.0. Use "_entity_access" requirement with relevant operation instead. See https://www.drupal.org/node/3161210', E_USER_DEPRECATED);
$this->nodeStorage = $entity_type_manager->getStorage('node');
}
/**
* Checks routing access for the node revision.
*
* @param \Symfony\Component\Routing\Route $route
* The route to check against.
* @param \Drupal\Core\Session\AccountInterface $account
* The currently logged in account.
* @param int $node_revision
* (optional) The node revision ID. If not specified, but $node is, access
* is checked for that object's revision.
* @param \Drupal\node\NodeInterface $node
* (optional) A node object. Used for checking access to a node's default
* revision when $node_revision is unspecified. Ignored when $node_revision
* is specified. If neither $node_revision nor $node are specified, then
* access is denied.
*
* @return \Drupal\Core\Access\AccessResultInterface
* The access result.
*/
public function access(Route $route, AccountInterface $account, $node_revision = NULL, NodeInterface $node = NULL) {
if ($node_revision) {
$node = $this->nodeStorage->loadRevision($node_revision);
}
$operation = $route->getRequirement('_access_node_revision');
return AccessResult::allowedIf($node && $this->checkAccess($node, $account, $operation))->cachePerPermissions()->addCacheableDependency($node);
}
/**
* Checks node revision access.
*
* @param \Drupal\node\NodeInterface $node
* The node to check.
* @param \Drupal\Core\Session\AccountInterface $account
* A user object representing the user for whom the operation is to be
* performed.
* @param string $op
* (optional) The specific operation being checked. Defaults to 'view.'
*
* @return bool
* TRUE if the operation may be performed, FALSE otherwise.
*/
public function checkAccess(NodeInterface $node, AccountInterface $account, $op = 'view') {
// Converts legacy operations for this access check to new revision
// operation found in access control handler.
$entity_operation_map = [
'view' => 'view all revisions',
'update' => 'revert revision',
'delete' => 'delete revision',
];
return isset($entity_operation_map[$op]) ?
$node->access($entity_operation_map[$op], $account) :
FALSE;
}
}

View File

@ -63,16 +63,12 @@ class NodeAccessControlHandler extends EntityAccessControlHandler implements Nod
* The entity type definition.
* @param \Drupal\node\NodeGrantDatabaseStorageInterface $grant_storage
* The node grant storage.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface|null $entity_type_manager
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
*/
public function __construct(EntityTypeInterface $entity_type, NodeGrantDatabaseStorageInterface $grant_storage, EntityTypeManagerInterface $entity_type_manager = NULL) {
public function __construct(EntityTypeInterface $entity_type, NodeGrantDatabaseStorageInterface $grant_storage, EntityTypeManagerInterface $entity_type_manager) {
parent::__construct($entity_type);
$this->grantStorage = $grant_storage;
if (!isset($entity_type_manager)) {
@trigger_error('Calling ' . __METHOD__ . '() without the $entity_type_manager argument is deprecated in drupal:9.3.0 and will be required in drupal:10.0.0. See https://www.drupal.org/node/3214171', E_USER_DEPRECATED);
$entity_type_manager = \Drupal::entityTypeManager();
}
$this->entityTypeManager = $entity_type_manager;
}

View File

@ -1,127 +0,0 @@
<?php
namespace Drupal\node\Plugin\Condition;
use Drupal\Core\Condition\ConditionPluginBase;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides a 'Node Type' condition.
*
* @Condition(
* id = "node_type",
* label = @Translation("Node Bundle (Deprecated)"),
* context_definitions = {
* "node" = @ContextDefinition("entity:node", label = @Translation("Node"))
* }
* )
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0.
* Use \Drupal\Core\Entity\Plugin\Condition\EntityBundle instead.
*
* @see https://www.drupal.org/node/2983299
*/
class NodeType extends ConditionPluginBase implements ContainerFactoryPluginInterface {
/**
* The entity storage.
*
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
protected $entityStorage;
/**
* Creates a new NodeType instance.
*
* @param \Drupal\Core\Entity\EntityStorageInterface $entity_storage
* The entity storage.
* @param array $configuration
* The plugin configuration, i.e. an array with configuration values keyed
* by configuration option name. The special key 'context' may be used to
* initialize the defined contexts by setting it to an array of context
* values keyed by context names.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
*/
public function __construct(EntityStorageInterface $entity_storage, array $configuration, $plugin_id, $plugin_definition) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
@trigger_error('\Drupal\node\Plugin\Condition\NodeType is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Drupal\Core\Entity\Plugin\Condition\EntityBundle instead. See https://www.drupal.org/node/2983299', E_USER_DEPRECATED);
$this->entityStorage = $entity_storage;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
$container->get('entity_type.manager')->getStorage('node_type'),
$configuration,
$plugin_id,
$plugin_definition
);
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$options = [];
$node_types = $this->entityStorage->loadMultiple();
foreach ($node_types as $type) {
$options[$type->id()] = $type->label();
}
$form['bundles'] = [
'#title' => $this->t('Node types'),
'#type' => 'checkboxes',
'#options' => $options,
'#default_value' => $this->configuration['bundles'],
];
return parent::buildConfigurationForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
$this->configuration['bundles'] = array_filter($form_state->getValue('bundles'));
parent::submitConfigurationForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function summary() {
if (count($this->configuration['bundles']) > 1) {
$bundles = $this->configuration['bundles'];
$last = array_pop($bundles);
$bundles = implode(', ', $bundles);
return $this->t('The node bundle is @bundles or @last', ['@bundles' => $bundles, '@last' => $last]);
}
$bundle = reset($this->configuration['bundles']);
return $this->t('The node bundle is @bundle', ['@bundle' => $bundle]);
}
/**
* {@inheritdoc}
*/
public function evaluate() {
if (empty($this->configuration['bundles']) && !$this->isNegated()) {
return TRUE;
}
$node = $this->getContextValue('node');
return !empty($this->configuration['bundles'][$node->getType()]);
}
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
return ['bundles' => []] + parent::defaultConfiguration();
}
}

View File

@ -70,16 +70,4 @@ class ViewMode extends ViewModeBase {
return $ids;
}
/**
* {@inheritdoc}
*/
public function calculateDependencies() {
$this->dependencies = parent::calculateDependencies();
if (isset($this->configuration['constants']['targetEntityType'])) {
@trigger_error('The constant targetEntityType is deprecated in drupal:9.2.0 and is removed in drupal:10.0.0. Use entity_type instead. See https://www.drupal.org/node/3208135', E_USER_DEPRECATED);
$this->addDependency('module', $this->entityTypeManager->getDefinition($this->configuration['constants']['targetEntityType'])->getProvider());
}
return $this->dependencies;
}
}

View File

@ -2,7 +2,6 @@
namespace Drupal\node\Plugin\views\argument;
use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait;
use Drupal\views\Plugin\views\argument\NumericArgument;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\node\NodeStorageInterface;
@ -14,13 +13,6 @@ use Drupal\node\NodeStorageInterface;
*/
class Vid extends NumericArgument {
use DeprecatedServicePropertyTrait;
/**
* {@inheritdoc}
*/
protected $deprecatedProperties = ['database' => 'database'];
/**
* The node storage.
*
@ -40,16 +32,8 @@ class Vid extends NumericArgument {
* @param \Drupal\node\NodeStorageInterface $node_storage
* The node storage.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, $node_storage) {
public function __construct(array $configuration, $plugin_id, $plugin_definition, NodeStorageInterface $node_storage) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
if (!$node_storage instanceof NodeStorageInterface) {
@trigger_error('Passing the database service to ' . __METHOD__ . '() is deprecated in drupal:9.2.0 and will be removed before drupal:10.0.0. See https://www.drupal.org/node/3178412', E_USER_DEPRECATED);
$node_storage = func_get_arg(4);
}
if (!$node_storage instanceof NodeStorageInterface) {
throw new \InvalidArgumentException('The fourth argument must implement \Drupal\node\NodeStorageInterface.');
}
$this->nodeStorage = $node_storage;
}

View File

@ -65,11 +65,7 @@ class Node extends WizardPluginBase {
* @param \Drupal\Core\Menu\MenuParentFormSelectorInterface $parent_form_selector
* The parent form selector service.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeBundleInfoInterface $bundle_info_service, EntityDisplayRepositoryInterface $entity_display_repository, EntityFieldManagerInterface $entity_field_manager, MenuParentFormSelectorInterface $parent_form_selector = NULL) {
if (!$parent_form_selector) {
@trigger_error('Calling ' . __METHOD__ . '() without the $parent_form_selector argument is deprecated in drupal:9.3.0 and the $parent_form_selector argument will be required in drupal:10.0.0. See https://www.drupal.org/node/3027559', E_USER_DEPRECATED);
$parent_form_selector = \Drupal::service('menu.parent_form_selector');
}
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeBundleInfoInterface $bundle_info_service, EntityDisplayRepositoryInterface $entity_display_repository, EntityFieldManagerInterface $entity_field_manager, MenuParentFormSelectorInterface $parent_form_selector) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $bundle_info_service, $parent_form_selector);
$this->entityDisplayRepository = $entity_display_repository;

View File

@ -1,42 +0,0 @@
<?php
namespace Drupal\Tests\node\Functional;
@trigger_error(__NAMESPACE__ . '\AssertButtonsTrait is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. There is no replacement. See https://www.drupal.org/node/3215411', E_USER_DEPRECATED);
/**
* Asserts that buttons are present on a page.
*/
trait AssertButtonsTrait {
/**
* Assert method to verify the buttons in the dropdown element.
*
* @param array $buttons
* A collection of buttons to assert for on the page.
* @param bool $dropbutton
* Whether to check if the buttons are in a dropbutton widget or not.
*/
public function assertButtons(array $buttons, $dropbutton = TRUE) {
// Verify that the number of buttons passed as parameters is
// available in the dropbutton widget.
if ($dropbutton) {
$count = count($buttons);
// Assert there is no save button.
$this->assertSession()->buttonNotExists('Save');
// Dropbutton elements.
$this->assertSession()->elementsCount('xpath', '//div[@class="dropbutton-wrapper"]//input[@type="submit"]', $count);
for ($i = 1; $i++; $i <= $count) {
$this->assertSession()->elementTextEquals('xpath', "(//div[@class='dropbutton-wrapper']//input[@type='submit'])[$i]", $buttons[$i - 1]);
}
}
else {
// Assert there is a save button.
$this->assertSession()->buttonExists('Save');
$this->assertSession()->responseNotContains('dropbutton-wrapper');
}
}
}

View File

@ -144,7 +144,6 @@ class NodeBlockFunctionalTest extends NodeTestBase {
$theme = \Drupal::service('theme_handler')->getDefault();
$this->drupalGet("admin/structure/block/add/system_powered_by_block/{$theme}");
$this->assertSession()->pageTextContains('Content type');
$this->assertSession()->pageTextNotContains('Content types (Deprecated)');
$edit = [
'id' => strtolower($this->randomMachineName()),
'region' => 'sidebar_first',
@ -234,33 +233,4 @@ class NodeBlockFunctionalTest extends NodeTestBase {
$this->assertSession()->linkByHrefExists($block->toUrl()->toString());
}
/**
* Tests customization of deprecated node type condition.
*
* @group legacy
*/
public function testDeprecatedNodeTypeCondition() {
$this->expectDeprecation('\Drupal\node\Plugin\Condition\NodeType is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Drupal\Core\Entity\Plugin\Condition\EntityBundle instead. See https://www.drupal.org/node/2983299');
$this->expectDeprecation("The 'condition.plugin.node_type' config schema is deprecated in drupal:9.3.0 and is removed from drupal 10.0.0. Use the 'entity_bundle:node_type' key instead to define a node type condition. See https://www.drupal.org/node/2983299.");
$this->drupalLogin($this->adminUser);
$this->drupalPlaceBlock('system_powered_by_block', [
'id' => 'powered_by_deprecated',
'visibility' => [
'node_type' => [
'bundles' => [
'article' => 'article',
],
],
],
'context_mapping' => ['node' => '@node.node_route_context:node'],
]);
// On an existing block with the deprecated plugin, the deprecated
// label is shown.
$this->drupalGet("admin/structure/block/manage/powered_by_deprecated");
$this->assertSession()->pageTextContains('Content type');
$this->assertSession()->pageTextContains('Content types (Deprecated)');
$this->submitForm([], 'Save');
}
}

View File

@ -1,202 +0,0 @@
<?php
namespace Drupal\Tests\node\Functional;
use Drupal\Tests\Traits\Core\GeneratePermutationsTrait;
/**
* Tests user permissions for node revisions.
*
* @group node
* @group legacy
*/
class NodeRevisionPermissionsTest extends NodeTestBase {
use GeneratePermutationsTrait;
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* The node revisions.
*
* @var array
*/
protected $nodeRevisions = [];
/**
* The accounts.
*
* @var array
*/
protected $accounts = [];
/**
* Map revision permission names to node revision access ops.
*
* @var array
*/
protected $map = [
'view' => 'view all revisions',
'update' => 'revert all revisions',
'delete' => 'delete all revisions',
];
/**
* Map revision permission names to node type revision access ops.
*
* @var array
*/
protected $typeMap = [
'view' => 'view page revisions',
'update' => 'revert page revisions',
'delete' => 'delete page revisions',
];
protected function setUp(): void {
parent::setUp();
$types = ['page', 'article'];
foreach ($types as $type) {
// Create a node with several revisions.
$nodes[$type] = $this->drupalCreateNode(['type' => $type]);
$this->nodeRevisions[$type][] = $nodes[$type];
for ($i = 0; $i < 3; $i++) {
// Create a revision for the same nid and settings with a random log.
$revision = clone $nodes[$type];
$revision->setNewRevision();
$revision->revision_log = $this->randomMachineName(32);
$revision->save();
$this->nodeRevisions[$type][] = $revision;
}
}
}
/**
* Tests general revision access permissions.
*/
public function testNodeRevisionAccessAnyType() {
$this->expectDeprecation('NodeRevisionAccessCheck is deprecated in drupal:9.3.0 and will be removed before drupal:10.0.0. Use "_entity_access" requirement with relevant operation instead. See https://www.drupal.org/node/3161210');
// Create three users, one with each revision permission.
foreach ($this->map as $op => $permission) {
// Create the user.
$account = $this->drupalCreateUser(
[
'access content',
'edit any page content',
'delete any page content',
$permission,
]
);
$account->op = $op;
$this->accounts[] = $account;
}
// Create an admin account (returns TRUE for all revision permissions).
$admin_account = $this->drupalCreateUser([
'access content',
'administer nodes',
]);
$admin_account->is_admin = TRUE;
$this->accounts['admin'] = $admin_account;
$accounts['admin'] = $admin_account;
// Create a normal account (returns FALSE for all revision permissions).
$normal_account = $this->drupalCreateUser();
$normal_account->op = FALSE;
$this->accounts[] = $normal_account;
$accounts[] = $normal_account;
$revision = $this->nodeRevisions['page'][1];
$parameters = [
'op' => array_keys($this->map),
'account' => $this->accounts,
];
$permutations = $this->generatePermutations($parameters);
$node_revision_access = \Drupal::service('access_check.node.revision');
$vids = \Drupal::entityQuery('node')
->allRevisions()
->accessCheck(FALSE)
->condition('nid', $revision->id())
->execute();
foreach ($permutations as $case) {
// Skip this test if there are no revisions for the node.
if (!($revision->isDefaultRevision() && (count($vids) == 1 || $case['op'] == 'update' || $case['op'] == 'delete'))) {
if (!empty($case['account']->is_admin) || $case['account']->hasPermission($this->map[$case['op']])) {
$this->assertTrue($node_revision_access->checkAccess($revision, $case['account'], $case['op']), "{$this->map[$case['op']]} granted.");
}
else {
$this->assertFalse($node_revision_access->checkAccess($revision, $case['account'], $case['op']), "{$this->map[$case['op']]} not granted.");
}
}
}
// 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->checkAccess($revision, $admin_account, 'invalid-op'), 'NodeRevisionAccessCheck() returns FALSE with an invalid op.');
}
/**
* Tests revision access permissions for a specific content type.
*/
public function testNodeRevisionAccessPerType() {
$this->expectDeprecation('NodeRevisionAccessCheck is deprecated in drupal:9.3.0 and will be removed before drupal:10.0.0. Use "_entity_access" requirement with relevant operation instead. See https://www.drupal.org/node/3161210');
// Create three users, one with each revision permission.
foreach ($this->typeMap as $op => $permission) {
// Create the user.
$account = $this->drupalCreateUser(
[
'access content',
'edit any page content',
'delete any page content',
$permission,
]
);
$account->op = $op;
$accounts[] = $account;
}
$parameters = [
'op' => array_keys($this->typeMap),
'account' => $accounts,
];
// Test that the accounts have access to the corresponding page revision
// permissions.
$revision = $this->nodeRevisions['page'][1];
$permutations = $this->generatePermutations($parameters);
$node_revision_access = \Drupal::service('access_check.node.revision');
$vids = \Drupal::entityQuery('node')
->allRevisions()
->accessCheck(FALSE)
->condition('nid', $revision->id())
->execute();
foreach ($permutations as $case) {
// Skip this test if there are no revisions for the node.
if (!($revision->isDefaultRevision() && (count($vids) == 1 || $case['op'] == 'update' || $case['op'] == 'delete'))) {
if (!empty($case['account']->is_admin) || $case['account']->hasPermission($this->typeMap[$case['op']])) {
$this->assertTrue($node_revision_access->checkAccess($revision, $case['account'], $case['op']), "{$this->typeMap[$case['op']]} granted.");
}
else {
$this->assertFalse($node_revision_access->checkAccess($revision, $case['account'], $case['op']), "{$this->typeMap[$case['op']]} not granted.");
}
}
}
// Test that the accounts have no access to the article revisions.
$revision = $this->nodeRevisions['article'][1];
foreach ($permutations as $case) {
$this->assertFalse($node_revision_access->checkAccess($revision, $case['account'], $case['op']), "{$this->typeMap[$case['op']]} did not grant revision permission for articles.");
}
}
}

View File

@ -1,95 +0,0 @@
<?php
namespace Drupal\Tests\node\Kernel;
use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
/**
* Tests that conditions, provided by the node module, are working properly.
*
* @group node
* @group legacy
*/
class NodeConditionTest extends EntityKernelTestBase {
protected static $modules = ['node'];
protected function setUp(): void {
parent::setUp();
// Create the node bundles required for testing.
$type = NodeType::create(['type' => 'page', 'name' => 'page']);
$type->save();
$type = NodeType::create(['type' => 'article', 'name' => 'article']);
$type->save();
$type = NodeType::create(['type' => 'test', 'name' => 'test']);
$type->save();
}
/**
* Tests conditions.
*/
public function testConditions() {
$this->expectDeprecation('\Drupal\node\Plugin\Condition\NodeType is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Drupal\Core\Entity\Plugin\Condition\EntityBundle instead. See https://www.drupal.org/node/2983299');
$manager = $this->container->get('plugin.manager.condition');
$this->createUser();
// Get some nodes of various types to check against.
$page = Node::create(['type' => 'page', 'title' => $this->randomMachineName(), 'uid' => 1]);
$page->save();
$article = Node::create(['type' => 'article', 'title' => $this->randomMachineName(), 'uid' => 1]);
$article->save();
$test = Node::create(['type' => 'test', 'title' => $this->randomMachineName(), 'uid' => 1]);
$test->save();
// Grab the node type condition and configure it to check against node type
// of 'article' and set the context to the page type node.
$condition = $manager->createInstance('node_type')
->setConfig('bundles', ['article' => 'article'])
->setContextValue('node', $page);
$this->assertFalse($condition->execute(), 'Page type nodes fail node type checks for articles.');
// Check for the proper summary.
$this->assertEquals('The node bundle is article', $condition->summary());
// Set the node type check to page.
$condition->setConfig('bundles', ['page' => 'page']);
$this->assertTrue($condition->execute(), 'Page type nodes pass node type checks for pages');
// Check for the proper summary.
$this->assertEquals('The node bundle is page', $condition->summary());
// Set the node type check to page or article.
$condition->setConfig('bundles', ['page' => 'page', 'article' => 'article']);
$this->assertTrue($condition->execute(), 'Page type nodes pass node type checks for pages or articles');
// Check for the proper summary.
$this->assertEquals('The node bundle is page or article', $condition->summary());
// Set the context to the article node.
$condition->setContextValue('node', $article);
$this->assertTrue($condition->execute(), 'Article type nodes pass node type checks for pages or articles');
// Set the context to the test node.
$condition->setContextValue('node', $test);
$this->assertFalse($condition->execute(), 'Test type nodes pass node type checks for pages or articles');
// Check a greater than 2 bundles summary scenario.
$condition->setConfig('bundles', ['page' => 'page', 'article' => 'article', 'test' => 'test']);
$this->assertEquals('The node bundle is page, article or test', $condition->summary());
}
/**
* @group legacy
*/
public function testLegacy() {
$this->expectDeprecation('Passing context values to plugins via configuration is deprecated in drupal:9.1.0 and will be removed before drupal:10.0.0. Instead, call ::setContextValue() on the plugin itself. See https://www.drupal.org/node/3120980');
$manager = $this->container->get('plugin.manager.condition');
$article = Node::create(['type' => 'article', 'title' => $this->randomMachineName(), 'uid' => 1]);
$article->save();
// Test Constructor injection.
$condition = $manager->createInstance('node_type', ['bundles' => ['article' => 'article'], 'context' => ['node' => $article]]);
$this->assertTrue($condition->execute(), 'Constructor injection of context and configuration working as anticipated.');
}
}

View File

@ -1,26 +0,0 @@
<?php
namespace Drupal\Tests\node\Kernel;
use Drupal\KernelTests\KernelTestBase;
/**
* @group node
* @group legacy
*/
class NodeDeprecationTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = ['node'];
/**
* @see node_mark()
*/
public function testNodeMarkDeprecation() {
$this->expectDeprecation("Calling drupal_static_reset() with 'node_mark' as argument is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. There is no replacement for this usage. See https://www.drupal.org/node/3037203");
drupal_static_reset('node_mark');
}
}

View File

@ -4,7 +4,6 @@ namespace Drupal\Tests\node\Kernel\Views;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
use Drupal\node\Plugin\views\argument\Vid;
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
use Drupal\views\Tests\ViewTestData;
use Drupal\views\Views;
@ -55,17 +54,4 @@ class ArgumentNodeRevisionIdTest extends ViewsKernelTestBase {
$this->assertIdenticalResultset($view_nid, [['title' => 'test2']]);
}
/**
* Tests the Vid argument deprecation.
*
* @group legacy
*/
public function testVidDeprecatedParameter() {
$this->expectDeprecation('Passing the database service to Drupal\node\Plugin\views\argument\Vid::__construct() is deprecated in drupal:9.2.0 and will be removed before drupal:10.0.0. See https://www.drupal.org/node/3178412');
$database = $this->container->get('database');
$node_storage = $this->container->get('entity_type.manager')->getStorage('node');
$vid = new Vid([], 'test_plugin', [], $database, $node_storage);
$this->assertNotNull($vid);
}
}

View File

@ -16,7 +16,6 @@ use Drupal\node\NodeGrantDatabaseStorageInterface;
use Drupal\node\NodeInterface;
use Drupal\node\NodeStorageInterface;
use Drupal\Tests\UnitTestCase;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Tests node operations.
@ -274,21 +273,4 @@ class NodeOperationAccessTest extends UnitTestCase {
return $data;
}
/**
* Tests NodeAccessControlHandler deprecation.
*
* @group legacy
*/
public function testNodeAccessControlHandlerDeprecation() {
$entity_type = $this->prophesize(EntityTypeInterface::class);
$entity_type->id()->willReturn(mt_rand(1, 128));
$node_grant_storage = $this->prophesize(NodeGrantDatabaseStorageInterface::class);
$entity_type_manager = $this->prophesize(EntityTypeManagerInterface::class);
$container = $this->prophesize(ContainerInterface::class);
$container->get('entity_type.manager')->willReturn($entity_type_manager->reveal());
\Drupal::setContainer($container->reveal());
$this->expectDeprecation('Calling Drupal\node\NodeAccessControlHandler::__construct() without the $entity_type_manager argument is deprecated in drupal:9.3.0 and will be required in drupal:10.0.0. See https://www.drupal.org/node/3214171');
new NodeAccessControlHandler($entity_type->reveal(), $node_grant_storage->reveal());
}
}

View File

@ -530,11 +530,6 @@ parameters:
count: 1
path: modules/node/tests/src/Functional/NodeAdminTest.php
-
message: "#^The \"access_check\\.node\\.revision\" service is deprecated\\. You should use the 'access_check\\.entity' service instead\\. See https\\://www\\.drupal\\.org/node/3161210$#"
count: 2
path: modules/node/tests/src/Functional/NodeRevisionPermissionsTest.php
-
message: "#^Call to deprecated constant REQUEST_TIME\\: Deprecated in drupal\\:8\\.3\\.0 and is removed from drupal\\:10\\.0\\.0\\. Use \\\\Drupal\\:\\:time\\(\\)\\-\\>getRequestTime\\(\\); $#"
count: 1