Caching improved.

This commit is contained in:
Michael Vogel 2012-03-10 18:19:00 +01:00
parent 74b3e9f273
commit 670b571c8a

View file

@ -874,25 +874,27 @@ function link_compare($a,$b) {
if(! function_exists('prepare_body')) { if(! function_exists('prepare_body')) {
function prepare_body($item,$attach = false) { function prepare_body($item,$attach = false) {
call_hooks('prepare_body_init', $item);
$cache = get_config('system','itemcache'); $cache = get_config('system','itemcache');
if (($cache != '')) { if (($cache != '')) {
$cachefile = $cache."/".$item["guid"]."-".strtotime($item["edited"])."-".$attach; $cachefile = $cache."/".$item["guid"]."-".strtotime($item["edited"])."-".$attach."-".hash("crc32", $item['body']);
if (file_exists($cachefile)) if (file_exists($cachefile))
return(file_get_contents($cachefile)); $s = file_get_contents($cachefile);
} else {
$s = prepare_text($item['body']);
call_hooks('prepare_body_init', $item); file_put_contents($cachefile, $s);
}
$s = prepare_text($item['body']); } else
$s = prepare_text($item['body']);
$prep_arr = array('item' => $item, 'html' => $s); $prep_arr = array('item' => $item, 'html' => $s);
call_hooks('prepare_body', $prep_arr); call_hooks('prepare_body', $prep_arr);
$s = $prep_arr['html']; $s = $prep_arr['html'];
if(! $attach) { if(! $attach) {
if ($cache != '')
file_put_contents($cachefile, $s);
return $s; return $s;
} }
@ -925,13 +927,9 @@ function prepare_body($item,$attach = false) {
$s .= '<div class="clear"></div></div>'; $s .= '<div class="clear"></div></div>';
} }
$prep_arr = array('item' => $item, 'html' => $s); $prep_arr = array('item' => $item, 'html' => $s);
call_hooks('prepare_body_final', $prep_arr); call_hooks('prepare_body_final', $prep_arr);
if ($cache != '')
file_put_contents($cachefile, $prep_arr['html']);
return $prep_arr['html']; return $prep_arr['html'];
}} }}