summaryrefslogtreecommitdiff
path: root/modules/comment
diff options
context:
space:
mode:
authorwebchick <webchick@24967.no-reply.drupal.org>2011-10-01 23:38:23 -0700
committerwebchick <webchick@24967.no-reply.drupal.org>2011-10-01 23:38:23 -0700
commitf3268d135d0d33c4ca93721ea1a7d426f4fd0427 (patch)
tree4aee4310061cdbce4a16df480391b9e513964d25 /modules/comment
parentde26c88c28367668c1a779a13925d31ea5ee35d0 (diff)
downloadbrdo-f3268d135d0d33c4ca93721ea1a7d426f4fd0427.tar.gz
brdo-f3268d135d0d33c4ca93721ea1a7d426f4fd0427.tar.bz2
Issue #1178580 by Dave Reid: Fixed PHP notices with [node:summary], [node:body], or [comment:body] if there is no body field or language mismatch.
Diffstat (limited to 'modules/comment')
-rw-r--r--modules/comment/comment.tokens.inc8
1 files changed, 5 insertions, 3 deletions
diff --git a/modules/comment/comment.tokens.inc b/modules/comment/comment.tokens.inc
index d62b7e2f8..c495ec35d 100644
--- a/modules/comment/comment.tokens.inc
+++ b/modules/comment/comment.tokens.inc
@@ -155,9 +155,11 @@ function comment_tokens($type, $tokens, array $data = array(), array $options =
break;
case 'body':
- $item = $comment->comment_body[LANGUAGE_NONE][0];
- $instance = field_info_instance('comment', 'body', 'comment_body');
- $replacements[$original] = $sanitize ? _text_sanitize($instance, LANGUAGE_NONE, $item, 'value') : $item['value'];
+ if ($items = field_get_items('comment', $comment, 'comment_body', $language_code)) {
+ $instance = field_info_instance('comment', 'body', 'comment_body');
+ $field_langcode = field_language('comment', $comment, 'comment_body', $language_code);
+ $replacements[$original] = $sanitize ? _text_sanitize($instance, $field_langcode, $items[0], 'value') : $items[0]['value'];
+ }
break;
// Comment related URLs.