diff --git a/core/modules/comment/src/CommentForm.php b/core/modules/comment/src/CommentForm.php index cf20762..0673132 100644 --- a/core/modules/comment/src/CommentForm.php +++ b/core/modules/comment/src/CommentForm.php @@ -160,7 +160,7 @@ public function form(array $form, FormStateInterface $form_state) { ); $owner = $comment->getOwner(); - $form['author']['admin_select'] = [ + $form['author']['uid'] = [ '#type' => 'entity_autocomplete', '#target_type' => 'user', '#default_value' => $owner->isAnonymous() ? NULL : $owner, @@ -258,7 +258,7 @@ public function buildEntity(array $form, FormStateInterface $form_state) { $comment->setCreatedTime(REQUEST_TIME); } // Empty author ID should revert to anonymous. - $author_id = $form_state->getValue('admin_select'); + $author_id = $form_state->getValue('uid'); if ($comment->id() && $this->currentUser->hasPermission('administer comments')) { // Admin can leave the author ID blank to revert to anonymous. $author_id = $author_id ?: 0; diff --git a/core/modules/comment/src/Tests/CommentAnonymousTest.php b/core/modules/comment/src/Tests/CommentAnonymousTest.php index 3a86499..3a8e55f 100644 --- a/core/modules/comment/src/Tests/CommentAnonymousTest.php +++ b/core/modules/comment/src/Tests/CommentAnonymousTest.php @@ -100,7 +100,7 @@ function testAnonymous() { // Make sure the user data appears correctly when editing the comment. $this->drupalLogin($this->adminUser); $this->drupalGet('comment/' . $anonymous_comment3->id() . '/edit'); - $this->assertFieldByName('admin_select', '', 'The author field is empty (i.e. anonymous) when editing the comment.'); + $this->assertFieldByName('uid', '', 'The author field is empty (i.e. anonymous) when editing the comment.'); $this->assertRaw($author_mail, "The anonymous user's email address is correct when editing the comment."); // Unpublish comment. diff --git a/core/modules/comment/src/Tests/CommentInterfaceTest.php b/core/modules/comment/src/Tests/CommentInterfaceTest.php index 2795628..0dc5ea2 100644 --- a/core/modules/comment/src/Tests/CommentInterfaceTest.php +++ b/core/modules/comment/src/Tests/CommentInterfaceTest.php @@ -83,7 +83,7 @@ public function testCommentInterface() { ))); // Test changing the comment author to "Anonymous". - $comment = $this->postComment(NULL, $comment->comment_body->value, $comment->getSubject(), array('admin_select' => '')); + $comment = $this->postComment(NULL, $comment->comment_body->value, $comment->getSubject(), array('uid' => '')); $this->assertTrue($comment->getAuthorName() == t('Anonymous') && $comment->getOwnerId() == 0, 'Comment author successfully changed to anonymous.'); // Test changing the comment author to an unverified user. @@ -95,7 +95,7 @@ public function testCommentInterface() { // Test changing the comment author to a verified user. $this->drupalGet('comment/' . $comment->id() . '/edit'); - $comment = $this->postComment(NULL, $comment->comment_body->value, $comment->getSubject(), array('admin_select' => $this->webUser->getUsername() . ' (' . $this->webUser->id() . ')')); + $comment = $this->postComment(NULL, $comment->comment_body->value, $comment->getSubject(), array('uid' => $this->webUser->getUsername() . ' (' . $this->webUser->id() . ')')); $this->assertTrue($comment->getAuthorName() == $this->webUser->getUsername() && $comment->getOwnerId() == $this->webUser->id(), 'Comment author successfully changed to a registered user.'); $this->drupalLogout(); diff --git a/core/modules/comment/src/Tests/CommentPreviewTest.php b/core/modules/comment/src/Tests/CommentPreviewTest.php index c05fbbe..0e2c917 100644 --- a/core/modules/comment/src/Tests/CommentPreviewTest.php +++ b/core/modules/comment/src/Tests/CommentPreviewTest.php @@ -144,7 +144,7 @@ function testCommentEditPreviewSave() { $date = new DrupalDateTime('2008-03-02 17:23'); $edit['subject[0][value]'] = $this->randomMachineName(8); $edit['comment_body[0][value]'] = $this->randomMachineName(16); - $edit['admin_select'] = $web_user->getUsername() . ' (' . $web_user->id() . ')'; + $edit['uid'] = $web_user->getUsername() . ' (' . $web_user->id() . ')'; $edit['date[date]'] = $date->format('Y-m-d'); $edit['date[time]'] = $date->format('H:i:s'); $raw_date = $date->getTimestamp(); @@ -164,7 +164,7 @@ function testCommentEditPreviewSave() { // Check that the subject, comment, author and date fields are displayed with the correct values. $this->assertFieldByName('subject[0][value]', $edit['subject[0][value]'], 'Subject field displayed.'); $this->assertFieldByName('comment_body[0][value]', $edit['comment_body[0][value]'], 'Comment field displayed.'); - $this->assertFieldByName('admin_select', $edit['admin_select'], 'Author field displayed.'); + $this->assertFieldByName('uid', $edit['uid'], 'Author field displayed.'); $this->assertFieldByName('date[date]', $edit['date[date]'], 'Date field displayed.'); $this->assertFieldByName('date[time]', $edit['date[time]'], 'Time field displayed.'); @@ -176,7 +176,7 @@ function testCommentEditPreviewSave() { $this->drupalGet('comment/' . $comment->id() . '/edit'); $this->assertFieldByName('subject[0][value]', $edit['subject[0][value]'], 'Subject field displayed.'); $this->assertFieldByName('comment_body[0][value]', $edit['comment_body[0][value]'], 'Comment field displayed.'); - $this->assertFieldByName('admin_select', $edit['admin_select'], 'Author field displayed.'); + $this->assertFieldByName('uid', $edit['uid'], 'Author field displayed.'); $this->assertFieldByName('date[date]', $expected_form_date, 'Date field displayed.'); $this->assertFieldByName('date[time]', $expected_form_time, 'Time field displayed.'); @@ -205,7 +205,7 @@ function testCommentEditPreviewSave() { $expected_created_time = $comment_loaded->getCreatedTime(); $this->drupalLogin($web_user); // Web user cannot change the comment author. - unset($edit['admin_select']); + unset($edit['uid']); $this->drupalPostForm('comment/' . $comment->id() . '/edit', $user_edit, t('Save')); $comment_storage->resetCache(array($comment->id())); $comment_loaded = Comment::load($comment->id()); diff --git a/core/modules/comment/src/Tests/CommentTranslationUITest.php b/core/modules/comment/src/Tests/CommentTranslationUITest.php index b8c56d9..88c1d2f 100644 --- a/core/modules/comment/src/Tests/CommentTranslationUITest.php +++ b/core/modules/comment/src/Tests/CommentTranslationUITest.php @@ -163,7 +163,7 @@ protected function doTestAuthoringInfo() { 'created' => REQUEST_TIME - mt_rand(0, 1000), ); $edit = array( - 'admin_select' => $user->getUsername() . '(' . $user->id() . ')', + 'uid' => $user->getUsername() . '(' . $user->id() . ')', 'date[date]' => format_date($values[$langcode]['created'], 'custom', 'Y-m-d'), 'date[time]' => format_date($values[$langcode]['created'], 'custom', 'H:i:s'), );