diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-04-22 10:12:25 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-04-22 10:12:25 +0000 |
commit | 186fb08d7b08ea5b4e557b4af11d97883d931382 (patch) | |
tree | c3a70d62f0e1e7c3d83e8924141d8f470d9ed3dc | |
parent | 4095b6cf996eb6c5da7e99f7dfb5801636f1a7dd (diff) | |
download | brdo-186fb08d7b08ea5b4e557b4af11d97883d931382.tar.gz brdo-186fb08d7b08ea5b4e557b4af11d97883d931382.tar.bz2 |
#777372 by cwgordon7, Gábor Hojtsy: Fixed Regression: anonymous comments cannot be edited on Drupal 7. (with tests)
-rw-r--r-- | modules/comment/comment.module | 15 | ||||
-rw-r--r-- | modules/comment/comment.test | 11 |
2 files changed, 17 insertions, 9 deletions
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'); |