comment_form_submit():
function comment_form_submit($form, &$form_state) {
$node = node_load($form_state['values']['nid']);
$comment = comment_form_submit_build_comment($form, $form_state);
if (user_access('post comments') && (user_access('administer comments') || $node->comment == COMMENT_NODE_OPEN)) {
// Save the anonymous user information to a cookie for reuse.
if (!$comment->uid) {
user_cookie_save(array_intersect_key($form_state['values'], array_flip(array('name', 'mail', 'homepage'))));
}
comment_save($comment);
When editing/moderating a comment from an anonymous user ($comment->uid == 0 && $GLOBALS['user']->uid != $comment->uid), then your author cookie is overwritten with the author information of the author of the comment you are editing.
Comments
Comment #1
grendzy commentedComment #2
dries commentedThis looks RTBC to me, although I haven't tested it. Leaving it RTBC for a bit.
Comment #3
sunLooked at this patch yesterday already, but wasn't really sure whether we shouldn't extend the old condition instead of replacing it, to make it more explicit.
The current patch should definitely fix the bug, but then again, neither the old nor new condition is 100% self-descriptive. I think I'd prefer to use both conditions.
Powered by Dreditor.
Comment #4
grendzy commentedok.
Comment #5
sunThank you! :)
Comment #6
dawehnerComment #7
dries commentedCommitted to 7.x and 8.x. Thanks!
Comment #8
bfroehle commentedUntagging since it's been committed to 7.x
Comment #9
andypost@Dries has commited a patch #1 not #3
D8 http://drupalcode.org/project/drupal.git/commitdiff/12165276c537f8ecf13a...
D7 http://drupalcode.org/project/drupal.git/commitdiff/62b8fd96ffbf0b5477f3...
Comment #10
sunNo cookies, @Dries!
Comment #11
grendzy commentedsun: can you explain a bit more? Are you asking for a new patch that addresses #3, or getting rid of the cookie storage entirely?
Personally I'd prefer this feature use localstorage but that's a different issue. :-)
Comment #12
sun@grendzy: @Dries committed the patch in #1, instead of the patch in #4.
Hence, we now need a patch that re-does #4 but based on latest HEAD... which in turn is a bit borderline to ask for, as it's only clarifying logic in the code (for humans/readers) without substantial logical difference... umph.
Alternatively, @Dries could reverse-apply #1, then apply #4 on top of it, and commit.
Comment #13
andypostSuppose #1 should work because a setting cookie used only for anonymous so when comment is edited by user (UID > 0) this condition is enough.
Attaching a patch against current state of head. I think this gives more readability to code and could prevent troubles with user masquerading modules.
Comment #14
sunThanks!
Comment #15
dries commentedI committed #1 because I didn't understand why #4 was needed. #1 seems more elegant to me.
What is the rationale for going with #4?
Comment #16
sunThe rationale was in #3:
The question is not elegance, but readability of code:
To which comment authors (not users) does this apply?
Does this only apply to anonymous users?
Does it or does it not apply to comments whose author is changed to Anonymous?
--
However, feel free to ignore me. This issue, code, and affected functionality is way too unimportant for getting into fundamental debates about elegance vs. performance vs. readability/clarity vs. style.
Which doesn't mean this discussion wouldn't be überimportant to have, but yeah, there's only so much time. ;)
Comment #17
andypostI think that check for authorship is important because there could be rules/triggers/actions that could be run from Anonymous against authored comments. OTOH this clarifies a reason to save cookie
Comment #18
catchTagging for backport.
Comment #19
catch#13: 1032024-reroll.patch queued for re-testing.
Comment #21
jibranI seen no cookie in D8 now.
This is from
Drupal\comment\CommentFormController::submit()Comment #22
andypostComment form does not store cookies anymore in d8