summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/comment/comment.module6
-rw-r--r--modules/comment/comment.test5
2 files changed, 8 insertions, 3 deletions
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index 4730dc0a3..7394eaa52 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -787,7 +787,7 @@ function comment_save($edit) {
$edit['timestamp'] = REQUEST_TIME;
}
- if ($edit['uid'] === $user->uid) { // '===' Need to modify anonymous users as well.
+ if ($edit['uid'] === $user->uid && isset($user->name)) { // '===' Need to modify anonymous users as well.
$edit['name'] = $user->name;
}
@@ -795,7 +795,7 @@ function comment_save($edit) {
->fields(array(
'nid' => $edit['nid'],
'pid' => empty($edit['pid']) ? 0 : $edit['pid'],
- 'uid' => empty($edit['uid']) ? 0 : $edit['uid'],
+ 'uid' => $edit['uid'],
'subject' => $edit['subject'],
'comment' => $edit['comment'],
'format' => $edit['comment_format'],
@@ -1466,7 +1466,7 @@ function comment_form(&$form_state, $edit, $title = NULL) {
);
$form['uid'] = array(
'#type' => 'value',
- '#value' => !empty($edit['uid']) ? $edit['uid'] : NULL,
+ '#value' => !empty($edit['uid']) ? $edit['uid'] : 0,
);
// Only show the save button if comment previews are optional or if we are
diff --git a/modules/comment/comment.test b/modules/comment/comment.test
index 70c6d6cba..a552adc01 100644
--- a/modules/comment/comment.test
+++ b/modules/comment/comment.test
@@ -413,6 +413,11 @@ class CommentAnonymous extends CommentHelperCase {
// Allow contact info.
$this->drupalLogin($this->admin_user);
$this->setCommentAnonymous('1');
+
+ // Attempt to edit anonymous comment.
+ $this->drupalGet('comment/edit/' . $anonymous_comment1->id);
+ $edited_comment = $this->postComment(NULL, $this->randomName(), $this->randomName());
+ $this->assertTrue($this->commentExists($edited_comment, FALSE), t('Modified reply found.'));
$this->drupalLogout();
// Post anonymous comment with contact info (optional).