Commit c6d9c07b authored by webchick's avatar webchick
Browse files

#446518 follow-up by sun: Removed logic branch in check_markup() for string being NULL.

parent 6e9eb545
......@@ -434,45 +434,40 @@ function filter_list_format($format) {
* elsewhere to avoid duplicate cache lookups and storage.
*/
function check_markup($text, $format = FILTER_FORMAT_DEFAULT, $langcode = '', $cache = TRUE) {
if (isset($text)) {
$format = filter_resolve_format($format);
// 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;
}
$format = filter_resolve_format($format);
// Convert all Windows and Mac newlines to a single newline,
// so filters only need to deal with one possibility.
$text = str_replace(array("\r\n", "\r"), "\n", $text);
// 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;
}
// Get a complete list of filters, ordered properly.
$filters = filter_list_format($format);
// Convert all Windows and Mac newlines to a single newline, so filters only
// need to deal with one possibility.
$text = str_replace(array("\r\n", "\r"), "\n", $text);
// Give filters the chance to escape HTML-like data such as code or formulas.
foreach ($filters as $filter) {
$filter_info = module_invoke($filter->module, 'filter_info');
if (isset($filter_info[$filter->name]['prepare callback']) && function_exists($filter_info[$filter->name]['prepare callback'])) {
$text = call_user_func($filter_info[$filter->name]['prepare callback'], $text, $format, $langcode, $cache_id);
}
}
// Get a complete list of filters, ordered properly.
$filters = filter_list_format($format);
// Perform filtering.
foreach ($filters as $filter) {
$filter_info = module_invoke($filter->module, 'filter_info');
if (isset($filter_info[$filter->name]['process callback']) && function_exists($filter_info[$filter->name]['process callback'])) {
$text = call_user_func($filter_info[$filter->name]['process callback'], $text, $format, $langcode, $cache_id);
}
// Give filters the chance to escape HTML-like data such as code or formulas.
foreach ($filters as $filter) {
$filter_info = module_invoke($filter->module, 'filter_info');
if (isset($filter_info[$filter->name]['prepare callback']) && function_exists($filter_info[$filter->name]['prepare callback'])) {
$text = call_user_func($filter_info[$filter->name]['prepare callback'], $text, $format, $langcode, $cache_id);
}
}
// Store in cache with a minimum expiration time of 1 day.
if ($cache && filter_format_allowcache($format)) {
cache_set($cache_id, $text, 'cache_filter', REQUEST_TIME + (60 * 60 * 24));
// Perform filtering.
foreach ($filters as $filter) {
$filter_info = module_invoke($filter->module, 'filter_info');
if (isset($filter_info[$filter->name]['process callback']) && function_exists($filter_info[$filter->name]['process callback'])) {
$text = call_user_func($filter_info[$filter->name]['process callback'], $text, $format, $langcode, $cache_id);
}
}
else {
$text = t('n/a');
// Store in cache with a minimum expiration time of 1 day.
if ($cache && filter_format_allowcache($format)) {
cache_set($cache_id, $text, 'cache_filter', REQUEST_TIME + (60 * 60 * 24));
}
return $text;
......
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