From 186fb08d7b08ea5b4e557b4af11d97883d931382 Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Thu, 22 Apr 2010 10:12:25 +0000 Subject: =?UTF-8?q?#777372=20by=20cwgordon7,=20G=C3=A1bor=20Hojtsy:=20Fixe?= =?UTF-8?q?d=20Regression:=20anonymous=20comments=20cannot=20be=20edited?= =?UTF-8?q?=20on=20Drupal=207.=20(with=20tests)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/comment/comment.module | 15 ++++++++------- modules/comment/comment.test | 11 +++++++++-- 2 files changed, 17 insertions(+), 9 deletions(-) (limited to 'modules/comment') diff --git a/modules/comment/comment.module b/modules/comment/comment.module index 0814c2624..94ba2ccd1 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -1778,15 +1778,16 @@ function comment_form($form, &$form_state, $comment) { '#weight' => -2, ); } - - // Sets the author form elements above the subject. - $form['author'] = array( - '#weight' => -2, - ); + else { + // Sets the author form elements above the subject. + $form['author'] = array( + '#weight' => -2, + ); + } // Prepare default values for form elements. if ($is_admin) { - $author = ($comment->uid && $comment->name ? $comment->name : $comment->registered_name); + $author = (!$comment->uid && $comment->name ? $comment->name : $comment->registered_name); $status = (isset($comment->status) ? $comment->status : COMMENT_NOT_PUBLISHED); $date = (!empty($comment->date) ? $comment->date : format_date($comment->changed, 'custom', 'Y-m-d H:i O')); } @@ -2010,7 +2011,7 @@ function comment_form_validate($form, &$form_state) { if ($form_state['values']['date'] && strtotime($form_state['values']['date']) === FALSE) { form_set_error('date', t('You have to specify a valid date.')); } - if ($form_state['values']['name'] && !$account = user_load_by_name($form_state['values']['name'])) { + if ($form_state['values']['name'] && !$form_state['values']['is_anonymous'] && !$account = user_load_by_name($form_state['values']['name'])) { form_set_error('name', t('You have to specify a valid author.')); } } diff --git a/modules/comment/comment.test b/modules/comment/comment.test index 66933615e..0a0794ddf 100644 --- a/modules/comment/comment.test +++ b/modules/comment/comment.test @@ -530,11 +530,18 @@ class CommentAnonymous extends CommentHelperCase { $this->assertFalse($this->commentExists($anonymous_comment3), t('Anonymous comment with contact info (required) not found.')); // Post comment with contact info (required). - $anonymous_comment3 = $this->postComment($this->node, $this->randomName(), $this->randomName(), array('mail' => 'tester@simpletest.org')); + $author_name = $this->randomName(); + $author_mail = $this->randomName() . '@example.com'; + $anonymous_comment3 = $this->postComment($this->node, $this->randomName(), $this->randomName(), array('name' => $author_name, 'mail' => $author_mail)); $this->assertTrue($this->commentExists($anonymous_comment3), t('Anonymous comment with contact info (required) found.')); - // Unpublish comment. + // Make sure the user data appears correctly when editing the comment. $this->drupalLogin($this->admin_user); + $this->drupalGet('comment/' . $anonymous_comment3->id . '/edit'); + $this->assertRaw($author_name, t("The anonymous user's name is correct when editing the comment.")); + $this->assertRaw($author_mail, t("The anonymous user's e-mail address is correct when editing the comment.")); + + // Unpublish comment. $this->performCommentOperation($anonymous_comment3, 'unpublish'); $this->drupalGet('admin/content/comment/approval'); -- cgit v1.2.3