Verified Commit d9059c06 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3323260 by Spokje, longwave: Deprecate node_revision_load() and friends

parent 23250f81
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@ public function testRevisions() {
    $this->assertFileIsPermanent($node_file_r2, 'Replacement file is permanent.');

    // Check that the original file is still in place on the first revision.
    $node = node_revision_load($node_vid_r1);
    $node = $node_storage->loadRevision($node_vid_r1);
    $current_file = File::load($node->{$field_name}->target_id);
    $this->assertEquals($node_file_r1->id(), $current_file->id(), 'Original file still in place after replacing file in new revision.');
    $this->assertFileExists($node_file_r1->getFileUri());
+4 −4
Original line number Diff line number Diff line
@@ -637,7 +637,7 @@ public function testDeleteRespectsUserCancelBlock() {
    $test_node = $node_storage->load($node->id());
    $this->assertNotNull($test_node, 'Node of the user is not deleted.');
    $this->assertTrue($test_node->isPublished(), 'Node of the user is published.');
    $test_node = node_revision_load($node->getRevisionId());
    $test_node = $node_storage->loadRevision($node->getRevisionId());
    $this->assertTrue($test_node->isPublished(), 'Node revision of the user is published.');
  }

@@ -667,7 +667,7 @@ public function testDeleteRespectsUserCancelBlockUnpublish() {
    $test_node = $node_storage->load($node->id());
    $this->assertNotNull($test_node, 'Node of the user is not deleted.');
    $this->assertFalse($test_node->isPublished(), 'Node of the user is no longer published.');
    $test_node = node_revision_load($node->getRevisionId());
    $test_node = $node_storage->loadRevision($node->getRevisionId());
    $this->assertFalse($test_node->isPublished(), 'Node revision of the user is no longer published.');
  }

@@ -713,7 +713,7 @@ public function testDeleteRespectsUserCancelBlockUnpublishAndProcessesBatches()
    }

    foreach ($nodes as $node) {
      $test_node = node_revision_load($node->getRevisionId());
      $test_node = $node_storage->loadRevision($node->getRevisionId());
      $this->assertFalse($test_node->isPublished(), 'Node revision of the user is no longer published.');
    }
  }
@@ -744,7 +744,7 @@ public function testDeleteRespectsUserCancelReassign() {
    $this->assertNotNull($test_node, 'Node of the user is not deleted.');
    $this->assertTrue($test_node->isPublished(), 'Node of the user is still published.');
    $this->assertEquals(0, $test_node->getOwnerId(), 'Node of the user has been attributed to anonymous user.');
    $test_node = node_revision_load($node->getRevisionId());
    $test_node = $node_storage->loadRevision($node->getRevisionId());
    $this->assertTrue($test_node->isPublished(), 'Node revision of the user is still published.');
    $this->assertEquals(0, $test_node->getRevisionUser()->id(), 'Node revision of the user has been attributed to anonymous user.');
  }
+19 −1
Original line number Diff line number Diff line
@@ -343,8 +343,14 @@ function node_entity_extra_field_info() {
 *
 * @return int
 *   The number of nodes whose node type field was modified.
 *
 * @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use
 *   \Drupal\Core\Entity\EntityStorageInterface::updateType instead.
 *
 * @see https://www.drupal.org/node/3323340
 */
function node_type_update_nodes($old_id, $new_id) {
  @trigger_error(__METHOD__ . ' is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use \Drupal\Core\Entity\EntityStorageInterface::updateType instead. See https://www.drupal.org/node/3323340', E_USER_DEPRECATED);
  return \Drupal::entityTypeManager()->getStorage('node')->updateType($old_id, $new_id);
}

@@ -356,8 +362,14 @@ function node_type_update_nodes($old_id, $new_id) {
 *
 * @return \Drupal\node\NodeInterface|null
 *   A fully-populated node entity, or NULL if the node is not found.
 *
 * @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use
 *   \Drupal\Core\Entity\EntityStorageInterface::loadRevision instead.
 *
 * @see https://www.drupal.org/node/3323340
 */
function node_revision_load($vid = NULL) {
  @trigger_error(__METHOD__ . ' is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use \Drupal\Core\Entity\EntityStorageInterface::loadRevision instead. See https://www.drupal.org/node/3323340', E_USER_DEPRECATED);
  return \Drupal::entityTypeManager()->getStorage('node')->loadRevision($vid);
}

@@ -366,8 +378,14 @@ function node_revision_load($vid = NULL) {
 *
 * @param int $revision_id
 *   The revision ID to delete.
 *
 * @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use
 *   \Drupal\Core\Entity\EntityStorageInterface::deleteRevision instead.
 *
 * @see https://www.drupal.org/node/3323340
 */
function node_revision_delete($revision_id) {
  @trigger_error(__METHOD__ . ' is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use \Drupal\Core\Entity\EntityStorageInterface::deleteRevision instead. See https://www.drupal.org/node/3323340', E_USER_DEPRECATED);
  \Drupal::entityTypeManager()->getStorage('node')->deleteRevision($revision_id);
}

@@ -682,7 +700,7 @@ function node_user_predelete($account) {
  $storage_controller->delete($nodes);
  $revisions = $storage_controller->userRevisionIds($account);
  foreach ($revisions as $revision) {
    node_revision_delete($revision);
    $storage_controller->deleteRevision($revision);
  }
}

+1 −1
Original line number Diff line number Diff line
@@ -181,7 +181,7 @@ public function postSave(EntityStorageInterface $storage, $update = TRUE) {
    parent::postSave($storage, $update);

    if ($update && $this->getOriginalId() != $this->id()) {
      $update_count = node_type_update_nodes($this->getOriginalId(), $this->id());
      $update_count = $storage->updateType($this->getOriginalId(), $this->id());
      if ($update_count) {
        \Drupal::messenger()->addStatus(\Drupal::translation()->formatPlural($update_count,
          'Changed the content type of 1 post from %old-type to %type.',
+3 −2
Original line number Diff line number Diff line
@@ -126,8 +126,9 @@ public function testNodeEdit() {
    $this->assertSame($node->getOwnerId(), $revised_node->getOwnerId(), 'The node author has been preserved.');
    // Ensure that the revision authors are different since the revisions were
    // made by different users.
    $first_node_version = node_revision_load($node->getRevisionId());
    $second_node_version = node_revision_load($revised_node->getRevisionId());
    $node_storage = \Drupal::service('entity_type.manager')->getStorage('node');
    $first_node_version = $node_storage->loadRevision($node->getRevisionId());
    $second_node_version = $node_storage->loadRevision($revised_node->getRevisionId());
    $this->assertNotSame($first_node_version->getRevisionUser()->id(), $second_node_version->getRevisionUser()->id(), 'Each revision has a distinct user.');

    // Check if the node revision checkbox is rendered on node edit form.
Loading