From d21afb80d69fae7963df0639c36b825459c35948 Mon Sep 17 00:00:00 2001 From: catch <catch@35733.no-reply.drupal.org> Date: Tue, 26 Nov 2019 13:27:21 +0000 Subject: [PATCH] Issue #3093132 by Sam152, Dinesh18: Remove isLatestRevision, getLatestRevision, getLatestRevisionId from the ModerationInformation service --- .../src/ModerationInformation.php | 29 --------- .../src/ModerationInformationInterface.php | 56 ---------------- .../src/Kernel/ModerationInformationTest.php | 64 ------------------- .../tests/src/Kernel/NodeAccessTest.php | 20 ------ 4 files changed, 169 deletions(-) diff --git a/core/modules/content_moderation/src/ModerationInformation.php b/core/modules/content_moderation/src/ModerationInformation.php index dd80ccbc0146..f590a3262727 100644 --- a/core/modules/content_moderation/src/ModerationInformation.php +++ b/core/modules/content_moderation/src/ModerationInformation.php @@ -82,27 +82,6 @@ public function shouldModerateEntitiesOfBundle(EntityTypeInterface $entity_type, return FALSE; } - /** - * {@inheritdoc} - */ - public function getLatestRevision($entity_type_id, $entity_id) { - @trigger_error(__METHOD__ . ' is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use RevisionableStorageInterface::getLatestRevisionId() and RevisionableStorageInterface::loadRevision() instead. See https://www.drupal.org/node/3087295', E_USER_DEPRECATED); - /** @var \Drupal\Core\Entity\ContentEntityStorageInterface $storage */ - $storage = $this->entityTypeManager->getStorage($entity_type_id); - return $storage->loadRevision($storage->getLatestRevisionId($entity_id)); - } - - /** - * {@inheritdoc} - */ - public function getLatestRevisionId($entity_type_id, $entity_id) { - @trigger_error(__METHOD__ . ' is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use RevisionableStorageInterface::getLatestRevisionId() instead. See https://www.drupal.org/node/3087295', E_USER_DEPRECATED); - /** @var \Drupal\Core\Entity\ContentEntityStorageInterface $storage */ - if ($storage = $this->entityTypeManager->getStorage($entity_type_id)) { - return $storage->getLatestRevisionId($entity_id); - } - } - /** * {@inheritdoc} */ @@ -133,14 +112,6 @@ public function getAffectedRevisionTranslation(ContentEntityInterface $entity) { } } - /** - * {@inheritdoc} - */ - public function isLatestRevision(ContentEntityInterface $entity) { - @trigger_error(__METHOD__ . ' is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use RevisionableInterface::isLatestRevision() instead. See https://www.drupal.org/node/3087295', E_USER_DEPRECATED); - return $entity->isLatestRevision(); - } - /** * {@inheritdoc} */ diff --git a/core/modules/content_moderation/src/ModerationInformationInterface.php b/core/modules/content_moderation/src/ModerationInformationInterface.php index ae915a9a609a..9b750637d415 100644 --- a/core/modules/content_moderation/src/ModerationInformationInterface.php +++ b/core/modules/content_moderation/src/ModerationInformationInterface.php @@ -58,45 +58,6 @@ public function shouldModerateEntitiesOfBundle(EntityTypeInterface $entity_type, */ public function isModeratedEntityType(EntityTypeInterface $entity_type); - /** - * Loads the latest revision of a specific entity. - * - * @param string $entity_type_id - * The entity type ID. - * @param int $entity_id - * The entity ID. - * - * @return \Drupal\Core\Entity\ContentEntityInterface|null - * The latest entity revision or NULL, if the entity type / entity doesn't - * exist. - * - * @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use - * RevisionableStorageInterface::getLatestRevisionId and - * RevisionableStorageInterface::loadRevision instead. - * - * @see https://www.drupal.org/node/3087295 - */ - public function getLatestRevision($entity_type_id, $entity_id); - - /** - * Returns the revision ID of the latest revision of the given entity. - * - * @param string $entity_type_id - * The entity type ID. - * @param int $entity_id - * The entity ID. - * - * @return int - * The revision ID of the latest revision for the specified entity, or - * NULL if there is no such entity. - * - * @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use - * RevisionableStorageInterface::getLatestRevisionId instead. - * - * @see https://www.drupal.org/node/3087295 - */ - public function getLatestRevisionId($entity_type_id, $entity_id); - /** * Returns the revision ID of the default revision for the specified entity. * @@ -122,23 +83,6 @@ public function getDefaultRevisionId($entity_type_id, $entity_id); */ public function getAffectedRevisionTranslation(ContentEntityInterface $entity); - /** - * Determines if an entity is a latest revision. - * - * @param \Drupal\Core\Entity\ContentEntityInterface $entity - * A revisionable content entity. - * - * @return bool - * TRUE if the specified object is the latest revision of its entity, - * FALSE otherwise. - * - * @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use - * RevisionableInterface::isLatestRevision instead. - * - * @see https://www.drupal.org/node/3087295 - */ - public function isLatestRevision(ContentEntityInterface $entity); - /** * Determines if a pending revision exists for the specified entity. * diff --git a/core/modules/content_moderation/tests/src/Kernel/ModerationInformationTest.php b/core/modules/content_moderation/tests/src/Kernel/ModerationInformationTest.php index e3852ad592f4..29b4baf48189 100644 --- a/core/modules/content_moderation/tests/src/Kernel/ModerationInformationTest.php +++ b/core/modules/content_moderation/tests/src/Kernel/ModerationInformationTest.php @@ -78,70 +78,6 @@ public function testGetDefaultRevisionId() { $this->assertSame(1, $default_revision_id); } - /** - * @covers ::getLatestRevisionId - * @group legacy - * @expectedDeprecation Drupal\content_moderation\ModerationInformation::getLatestRevisionId is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use RevisionableStorageInterface::getLatestRevisionId() instead. See https://www.drupal.org/node/3087295 - */ - public function testGetLatestRevisionId() { - $entity_test_rev = EntityTestRev::create([ - 'name' => 'Default Revision', - 'moderation_state' => 'published', - ]); - $entity_test_rev->save(); - - $entity_test_rev->name = 'Pending revision'; - $entity_test_rev->moderation_state = 'draft'; - $entity_test_rev->save(); - - // Check that moderation information service returns the correct latest - // revision ID. - $latest_revision_id = $this->moderationInformation->getLatestRevisionId('entity_test_rev', $entity_test_rev->id()); - $this->assertSame(2, $latest_revision_id); - } - - /** - * @covers ::getLatestRevision - * @group legacy - * @expectedDeprecation Drupal\content_moderation\ModerationInformation::getLatestRevision is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use RevisionableStorageInterface::getLatestRevisionId() and RevisionableStorageInterface::loadRevision() instead. See https://www.drupal.org/node/3087295 - */ - public function testGetLatestRevision() { - $entity_test_rev = EntityTestRev::create([ - 'name' => 'Default Revision', - 'moderation_state' => 'published', - ]); - $entity_test_rev->save(); - - $entity_test_rev->name = 'Pending revision'; - $entity_test_rev->moderation_state = 'draft'; - $entity_test_rev->save(); - - $latest_revision = $this->moderationInformation->getLatestRevision('entity_test_rev', $entity_test_rev->id()); - $this->assertEquals(2, $latest_revision->getRevisionId()); - } - - /** - * @covers ::isLatestRevision - * @group legacy - * @expectedDeprecation Drupal\content_moderation\ModerationInformation::isLatestRevision is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use RevisionableInterface::isLatestRevision() instead. See https://www.drupal.org/node/3087295 - */ - public function testIsLatestRevision() { - $entity_test_rev = EntityTestRev::create([ - 'name' => 'Default Revision', - 'moderation_state' => 'published', - ]); - $entity_test_rev->save(); - - $old_revision = clone $entity_test_rev; - - $entity_test_rev->name = 'Pending revision'; - $entity_test_rev->moderation_state = 'draft'; - $entity_test_rev->save(); - - $this->assertFalse($this->moderationInformation->isLatestRevision($old_revision)); - $this->assertTrue($this->moderationInformation->isLatestRevision($entity_test_rev)); - } - /** * @covers ::isDefaultRevisionPublished * @dataProvider isDefaultRevisionPublishedTestCases diff --git a/core/modules/content_moderation/tests/src/Kernel/NodeAccessTest.php b/core/modules/content_moderation/tests/src/Kernel/NodeAccessTest.php index 50d7f7acf3a2..09220186d8f2 100644 --- a/core/modules/content_moderation/tests/src/Kernel/NodeAccessTest.php +++ b/core/modules/content_moderation/tests/src/Kernel/NodeAccessTest.php @@ -84,24 +84,4 @@ public function testGetDefaultRevisionId() { $this->assertEquals($node->getRevisionId(), $this->moderationInformation->getDefaultRevisionId('node', $node->id())); } - /** - * @covers \Drupal\content_moderation\ModerationInformation::getLatestRevisionId - * @group legacy - * @expectedDeprecation Drupal\content_moderation\ModerationInformation::getLatestRevisionId is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use RevisionableStorageInterface::getLatestRevisionId() instead. See https://www.drupal.org/node/3087295 - */ - public function testGetLatestRevisionId() { - // Create an admin user. - $user = $this->createUser([], NULL, TRUE); - \Drupal::currentUser()->setAccount($user); - - // Create a node. - $node = $this->createNode(['type' => 'page']); - $this->assertEquals($node->getRevisionId(), $this->moderationInformation->getLatestRevisionId('node', $node->id())); - - // Create a non-admin user. - $user = $this->createUser(); - \Drupal::currentUser()->setAccount($user); - $this->assertEquals($node->getRevisionId(), $this->moderationInformation->getLatestRevisionId('node', $node->id())); - } - } -- GitLab