Skip to content
Snippets Groups Projects
Commit 20788221 authored by catch's avatar catch
Browse files

Issue #1178580 by Dave Reid: Fixed PHP notices with [node:summary],...

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.
parent f467f25b
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -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.
......
......@@ -135,11 +135,11 @@ function node_tokens($type, $tokens, array $data = array(), array $options = arr
case 'body':
case 'summary':
if (!empty($node->body)) {
$item = $node->body[$node->language][0];
if ($items = field_get_items('node', $node, 'body', $language_code)) {
$column = ($name == 'body') ? 'value' : 'summary';
$instance = field_info_instance('node', 'body', $node->type);
$replacements[$original] = $sanitize ? _text_sanitize($instance, $node->language, $item, $column) : $item[$column];
$field_langcode = field_language('node', $node, 'body', $language_code);
$replacements[$original] = $sanitize ? _text_sanitize($instance, $field_langcode, $items[0], $column) : $items[0][$column];
}
break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment