Commit 7ed3cf3b authored by webchick's avatar webchick

#569238 by sun, swentel, catch: Changed Make check_markup() not cache by default.

parent 7bcd22f1
......@@ -195,7 +195,7 @@ function block_block_save($delta = 0, $edit = array()) {
*/
function block_block_view($delta = 0, $edit = array()) {
$block = db_query('SELECT body, format FROM {block_custom} WHERE bid = :bid', array(':bid' => $delta))->fetchObject();
$data['content'] = check_markup($block->body, $block->format);
$data['content'] = check_markup($block->body, $block->format, '', TRUE);
return $data;
}
......
......@@ -841,7 +841,7 @@ function comment_build_content($comment, $node, $build_mode = 'full') {
// Build comment body.
$comment->content['comment_body'] = array(
'#markup' => check_markup($comment->comment, $comment->format),
'#markup' => check_markup($comment->comment, $comment->format, '', TRUE),
);
$comment->content += field_attach_view('comment', $comment, $build_mode);
......@@ -1158,7 +1158,7 @@ function comment_node_update_index($node) {
':status' => COMMENT_PUBLISHED
));
foreach ($comments as $comment) {
$text .= '<h2>' . check_plain($comment->subject) . '</h2>' . check_markup($comment->comment, $comment->format);
$text .= '<h2>' . check_plain($comment->subject) . '</h2>' . check_markup($comment->comment, $comment->format, '', TRUE);
}
}
return $text;
......
......@@ -175,7 +175,7 @@ function comment_tokens($type, $tokens, array $data = array(), array $options =
break;
case 'body':
$replacements[$original] = $sanitize ? check_markup($comment->comment, $comment->format) : $replacements[$original] = $comment->comment;
$replacements[$original] = $sanitize ? check_markup($comment->comment, $comment->format, '', TRUE) : $comment->comment;
break;
// Comment related URLs.
......
......@@ -278,9 +278,9 @@ function hook_field_load($obj_type, $objects, $field, $instances, $langcode, &$i
// handled by hook_field_sanitize().
$format = $item['format'];
if (filter_format_allowcache($format)) {
$items[$id][$delta]['safe'] = isset($item['value']) ? check_markup($item['value'], $format, $langcode, FALSE) : '';
$items[$id][$delta]['safe'] = isset($item['value']) ? check_markup($item['value'], $format, $langcode) : '';
if ($field['type'] == 'text_with_summary') {
$items[$id][$delta]['safe_summary'] = isset($item['summary']) ? check_markup($item['summary'], $format, $langcode, FALSE) : '';
$items[$id][$delta]['safe_summary'] = isset($item['summary']) ? check_markup($item['summary'], $format, $langcode) : '';
}
}
}
......@@ -322,9 +322,9 @@ function hook_field_sanitize($obj_type, $object, $field, $instance, $langcode, &
if (!isset($items[$delta]['safe'])) {
if (!empty($instance['settings']['text_processing'])) {
$format = $item['format'];
$items[$delta]['safe'] = isset($item['value']) ? check_markup($item['value'], $format, $langcode) : '';
$items[$delta]['safe'] = isset($item['value']) ? check_markup($item['value'], $format, $langcode, TRUE) : '';
if ($field['type'] == 'text_with_summary') {
$items[$delta]['safe_summary'] = isset($item['summary']) ? check_markup($item['summary'], $format, $langcode) : '';
$items[$delta]['safe_summary'] = isset($item['summary']) ? check_markup($item['summary'], $format, $langcode, TRUE) : '';
}
}
else {
......
......@@ -207,9 +207,9 @@ function text_field_load($obj_type, $objects, $field, $instances, $langcode, &$i
// handled by text_field_sanitize().
$format = $item['format'];
if (filter_format_allowcache($format)) {
$items[$id][$delta]['safe'] = isset($item['value']) ? check_markup($item['value'], $format, $langcode, FALSE) : '';
$items[$id][$delta]['safe'] = isset($item['value']) ? check_markup($item['value'], $format, $langcode) : '';
if ($field['type'] == 'text_with_summary') {
$items[$id][$delta]['safe_summary'] = isset($item['summary']) ? check_markup($item['summary'], $format, $langcode, FALSE) : '';
$items[$id][$delta]['safe_summary'] = isset($item['summary']) ? check_markup($item['summary'], $format, $langcode) : '';
}
}
}
......@@ -236,9 +236,9 @@ function text_field_sanitize($obj_type, $object, $field, $instance, $langcode, &
if (!isset($items[$delta]['safe'])) {
if (!empty($instance['settings']['text_processing'])) {
$format = $item['format'];
$items[$delta]['safe'] = isset($item['value']) ? check_markup($item['value'], $format, $langcode) : '';
$items[$delta]['safe'] = isset($item['value']) ? check_markup($item['value'], $format, $langcode, TRUE) : '';
if ($field['type'] == 'text_with_summary') {
$items[$delta]['safe_summary'] = isset($item['summary']) ? check_markup($item['summary'], $format, $langcode) : '';
$items[$delta]['safe_summary'] = isset($item['summary']) ? check_markup($item['summary'], $format, $langcode, TRUE) : '';
}
}
else {
......
......@@ -692,15 +692,19 @@ function filter_list_format($format, $include_disabled = FALSE) {
* The caller may set this to FALSE when the output is already cached
* elsewhere to avoid duplicate cache lookups and storage.
*/
function check_markup($text, $format = NULL, $langcode = '', $cache = TRUE) {
function check_markup($text, $format = NULL, $langcode = '', $cache = FALSE) {
if (empty($format)) {
$format = filter_fallback_format();
}
$cache = $cache && filter_format_allowcache($format);
$cache_id = '';
// Check for a cached version of this piece of text.
$cache_id = $format . ':' . $langcode . ':' . md5($text);
if ($cache && $cached = cache_get($cache_id, 'cache_filter')) {
return $cached->data;
if ($cache) {
$cache_id = $format . ':' . $langcode . ':' . md5($text);
if ($cached = cache_get($cache_id, 'cache_filter')) {
return $cached->data;
}
}
// Convert all Windows and Mac newlines to a single newline, so filters only
......@@ -726,7 +730,7 @@ function check_markup($text, $format = NULL, $langcode = '', $cache = TRUE) {
}
// Store in cache with a minimum expiration time of 1 day.
if ($cache && filter_format_allowcache($format)) {
if ($cache) {
cache_set($cache_id, $text, 'cache_filter', REQUEST_TIME + (60 * 60 * 24));
}
......
......@@ -486,7 +486,7 @@ function hook_node_update_index($node) {
$text = '';
$comments = db_query('SELECT subject, comment, format FROM {comment} WHERE nid = :nid AND status = :status', array(':nid' => $node->nid, ':status' => COMMENT_PUBLISHED));
foreach ($comments as $comment) {
$text .= '<h2>' . check_plain($comment->subject) . '</h2>' . check_markup($comment->comment, $comment->format);
$text .= '<h2>' . check_plain($comment->subject) . '</h2>' . check_markup($comment->comment, $comment->format, '', TRUE);
}
return $text;
}
......
......@@ -280,7 +280,7 @@ function profile_view_field($account, $field) {
if (isset($account->{$field->name}) && $value = $account->{$field->name}) {
switch ($field->type) {
case 'textarea':
return check_markup($value, filter_default_format($account));
return check_markup($value, filter_default_format($account), '', TRUE);
case 'textfield':
case 'selection':
return $browse ? l($value, 'profile/' . $field->name . '/' . $value) : check_plain($value);
......
......@@ -2852,7 +2852,7 @@ function user_forms() {
*/
function user_comment_view($comment) {
if (variable_get('user_signatures', 0) && !empty($comment->signature)) {
$comment->signature = check_markup($comment->signature, $comment->format);
$comment->signature = check_markup($comment->signature, $comment->format, '', TRUE);
}
else {
$comment->signature = '';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment