From 0fa506d3f41c4c1c6e4bb2dd0fa5b3c318e87154 Mon Sep 17 00:00:00 2001
From: Andrei Mateescu <andrei@xns.ro>
Date: Mon, 20 Jun 2011 23:41:43 +0300
Subject: [PATCH] Issue #816246 by amateescu and moritzz: Token [comment-author-name] doesn't return anything for anonymous users.

---
 token.test        |    1 +
 token_comment.inc |    2 +-
 2 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/token.test b/token.test
index cc9dec8..cfac2cf 100644
--- a/token.test
+++ b/token.test
@@ -365,6 +365,7 @@ class TokenCommentTestCase extends TokenTestHelper {
       'comment-since' => format_interval($time - 457747200),
       'comment-node-title' => check_plain($this->node->title),
       'comment-node-title-raw' => $this->node->title,
+      'comment-author-name' => variable_get('anonymous', t('Anonymous')),
     );
     $this->assertTokens('comment', $comment, $tokens);
 
diff --git a/token_comment.inc b/token_comment.inc
index d7d206f..8bde794 100644
--- a/token_comment.inc
+++ b/token_comment.inc
@@ -27,7 +27,7 @@ function comment_token_values($type, $object = NULL, $options = array()) {
       $values['comment-nid']             = $comment->nid;
       $values['comment-title']           = check_plain($comment->subject);
       $values['comment-body']            = check_markup($comment->comment, $comment->format, FALSE);
-      $values['comment-author-name']     = check_plain($comment->name);
+      $values['comment-author-name']     = !empty($comment->name) ? check_plain($comment->name) : variable_get('anonymous', t('Anonymous'));
       $values['comment-author-uid']      = $comment->uid;
       $values['comment-author-homepage'] = check_url($comment->homepage);
 
-- 
1.7.4.msysgit.0

