From 2be39c73876f9d22f8cea40777d082e3fba4cbd4 Mon Sep 17 00:00:00 2001 From: Nathaniel Catchpole Date: Wed, 4 May 2016 14:11:49 +0100 Subject: [PATCH] Issue #2718583 by alexpott: Remove deprecated usages of Node::setRevisionAuthorId() and Node::getRevisionAuthor() --- core/modules/node/src/Controller/NodeController.php | 2 +- core/modules/node/src/Entity/Node.php | 4 ++-- core/modules/node/src/NodeForm.php | 2 +- .../node/src/Tests/Migrate/d6/MigrateNodeRevisionTest.php | 4 ++-- core/modules/node/src/Tests/NodeEditFormTest.php | 2 +- core/modules/node/src/Tests/NodeRevisionsTest.php | 4 ++-- .../node/tests/src/Kernel/Migrate/d6/MigrateNodeTest.php | 2 +- .../node/tests/src/Kernel/Migrate/d7/MigrateNodeTest.php | 2 +- core/modules/user/src/Tests/UserCancelTest.php | 2 +- 9 files changed, 12 insertions(+), 12 deletions(-) diff --git a/core/modules/node/src/Controller/NodeController.php b/core/modules/node/src/Controller/NodeController.php index edb5682311b..d555efd1c0e 100644 --- a/core/modules/node/src/Controller/NodeController.php +++ b/core/modules/node/src/Controller/NodeController.php @@ -182,7 +182,7 @@ class NodeController extends ControllerBase implements ContainerInjectionInterfa if ($revision->hasTranslation($langcode) && $revision->getTranslation($langcode)->isRevisionTranslationAffected()) { $username = [ '#theme' => 'username', - '#account' => $revision->getRevisionAuthor(), + '#account' => $revision->getRevisionUser(), ]; // Use revision link to link to revisions that are not active. diff --git a/core/modules/node/src/Entity/Node.php b/core/modules/node/src/Entity/Node.php index 0fb327d2bb0..51794be16e1 100644 --- a/core/modules/node/src/Entity/Node.php +++ b/core/modules/node/src/Entity/Node.php @@ -102,8 +102,8 @@ class Node extends ContentEntityBase implements NodeInterface { // If no revision author has been set explicitly, make the node owner the // revision author. - if (!$this->getRevisionAuthor()) { - $this->setRevisionAuthorId($this->getOwnerId()); + if (!$this->getRevisionUser()) { + $this->setRevisionUserId($this->getOwnerId()); } } diff --git a/core/modules/node/src/NodeForm.php b/core/modules/node/src/NodeForm.php index 0e0f1a9141d..4d1c42cd185 100644 --- a/core/modules/node/src/NodeForm.php +++ b/core/modules/node/src/NodeForm.php @@ -322,7 +322,7 @@ class NodeForm extends ContentEntityForm { $node->setNewRevision(); // If a new revision is created, save the current user as revision author. $node->setRevisionCreationTime(REQUEST_TIME); - $node->setRevisionAuthorId(\Drupal::currentUser()->id()); + $node->setRevisionUserId(\Drupal::currentUser()->id()); } else { $node->setNewRevision(FALSE); diff --git a/core/modules/node/src/Tests/Migrate/d6/MigrateNodeRevisionTest.php b/core/modules/node/src/Tests/Migrate/d6/MigrateNodeRevisionTest.php index dc1bafdf2ab..05be99fe40e 100644 --- a/core/modules/node/src/Tests/Migrate/d6/MigrateNodeRevisionTest.php +++ b/core/modules/node/src/Tests/Migrate/d6/MigrateNodeRevisionTest.php @@ -30,14 +30,14 @@ class MigrateNodeRevisionTest extends MigrateNodeTestBase { $this->assertIdentical('Test title rev 2', $node->getTitle()); $this->assertIdentical('body test rev 2', $node->body->value); $this->assertIdentical('teaser test rev 2', $node->body->summary); - $this->assertIdentical('2', $node->getRevisionAuthor()->id()); + $this->assertIdentical('2', $node->getRevisionUser()->id()); $this->assertIdentical('modified rev 2', $node->revision_log->value); $this->assertIdentical('1390095702', $node->getRevisionCreationTime()); $node = \Drupal::entityManager()->getStorage('node')->loadRevision(5); $this->assertIdentical('1', $node->id()); $this->assertIdentical('body test rev 3', $node->body->value); - $this->assertIdentical('1', $node->getRevisionAuthor()->id()); + $this->assertIdentical('1', $node->getRevisionUser()->id()); $this->assertIdentical('modified rev 3', $node->revision_log->value); $this->assertIdentical('1390095703', $node->getRevisionCreationTime()); } diff --git a/core/modules/node/src/Tests/NodeEditFormTest.php b/core/modules/node/src/Tests/NodeEditFormTest.php index 659567dc879..fe10b38f3cf 100644 --- a/core/modules/node/src/Tests/NodeEditFormTest.php +++ b/core/modules/node/src/Tests/NodeEditFormTest.php @@ -112,7 +112,7 @@ class NodeEditFormTest extends NodeTestBase { // made by different users. $first_node_version = node_revision_load($node->getRevisionId()); $second_node_version = node_revision_load($revised_node->getRevisionId()); - $this->assertNotIdentical($first_node_version->getRevisionAuthor()->id(), $second_node_version->getRevisionAuthor()->id(), 'Each revision has a distinct user.'); + $this->assertNotIdentical($first_node_version->getRevisionUser()->id(), $second_node_version->getRevisionUser()->id(), 'Each revision has a distinct user.'); } /** diff --git a/core/modules/node/src/Tests/NodeRevisionsTest.php b/core/modules/node/src/Tests/NodeRevisionsTest.php index a1047f59df3..a441c2416fb 100644 --- a/core/modules/node/src/Tests/NodeRevisionsTest.php +++ b/core/modules/node/src/Tests/NodeRevisionsTest.php @@ -104,10 +104,10 @@ class NodeRevisionsTest extends NodeTestBase { // Edit the 2nd revision with a different user. if ($i == 1) { $editor = $this->drupalCreateUser(); - $node->setRevisionAuthorId($editor->id()); + $node->setRevisionUserId($editor->id()); } else { - $node->setRevisionAuthorId($web_user->id()); + $node->setRevisionUserId($web_user->id()); } $node->save(); diff --git a/core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeTest.php b/core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeTest.php index 29bc9dcaf5a..7f07d115311 100644 --- a/core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeTest.php +++ b/core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeTest.php @@ -46,7 +46,7 @@ class MigrateNodeTest extends MigrateNodeTestBase { /** @var \Drupal\node\NodeInterface $node_revision */ $node_revision = \Drupal::entityManager()->getStorage('node')->loadRevision(1); $this->assertIdentical('Test title', $node_revision->getTitle()); - $this->assertIdentical('1', $node_revision->getRevisionAuthor()->id(), 'Node revision has the correct user'); + $this->assertIdentical('1', $node_revision->getRevisionUser()->id(), 'Node revision has the correct user'); // This is empty on the first revision. $this->assertIdentical(NULL, $node_revision->revision_log->value); $this->assertIdentical('This is a shared text field', $node->field_test->value); diff --git a/core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeTest.php b/core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeTest.php index 24676ddf5df..9b44690008d 100644 --- a/core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeTest.php +++ b/core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeTest.php @@ -110,7 +110,7 @@ class MigrateNodeTest extends MigrateDrupal7TestBase { $revision = \Drupal::entityManager()->getStorage('node')->loadRevision($id); $this->assertTrue($revision instanceof NodeInterface); $this->assertIdentical($title, $revision->getTitle()); - $this->assertIdentical($uid, $revision->getRevisionAuthor()->id()); + $this->assertIdentical($uid, $revision->getRevisionUser()->id()); $this->assertIdentical($log, $revision->revision_log->value); $this->assertIdentical($timestamp, $revision->getRevisionCreationTime()); } diff --git a/core/modules/user/src/Tests/UserCancelTest.php b/core/modules/user/src/Tests/UserCancelTest.php index 2dd80064a0f..fe2151610a8 100644 --- a/core/modules/user/src/Tests/UserCancelTest.php +++ b/core/modules/user/src/Tests/UserCancelTest.php @@ -353,7 +353,7 @@ class UserCancelTest extends WebTestBase { $test_node = $node_storage->load($node->id()); $this->assertTrue(($test_node->getOwnerId() == 0 && $test_node->isPublished()), 'Node of the user has been attributed to anonymous user.'); $test_node = node_revision_load($revision, TRUE); - $this->assertTrue(($test_node->getRevisionAuthor()->id() == 0 && $test_node->isPublished()), 'Node revision of the user has been attributed to anonymous user.'); + $this->assertTrue(($test_node->getRevisionUser()->id() == 0 && $test_node->isPublished()), 'Node revision of the user has been attributed to anonymous user.'); $node_storage->resetCache(array($revision_node->id())); $test_node = $node_storage->load($revision_node->id()); $this->assertTrue(($test_node->getOwnerId() != 0 && $test_node->isPublished()), "Current revision of the user's node was not attributed to anonymous user.");