aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMichael Vogel <icarus@dabo.de>2012-03-10 18:19:00 +0100
committerMichael Vogel <icarus@dabo.de>2012-03-10 18:19:00 +0100
commit670b571c8ac0532cc80fff6351f91b1b0fa58e0c (patch)
tree05fd0ffc9701d23a3bb28aa8cf54fc19d0a03aa6 /include
parent74b3e9f273b019729d213f3ccaeba1bb11d61d24 (diff)
downloadvolse-hubzilla-670b571c8ac0532cc80fff6351f91b1b0fa58e0c.tar.gz
volse-hubzilla-670b571c8ac0532cc80fff6351f91b1b0fa58e0c.tar.bz2
volse-hubzilla-670b571c8ac0532cc80fff6351f91b1b0fa58e0c.zip
Caching improved.
Diffstat (limited to 'include')
-rw-r--r--include/text.php24
1 files changed, 11 insertions, 13 deletions
diff --git a/include/text.php b/include/text.php
index 38736d836..5bf815105 100644
--- a/include/text.php
+++ b/include/text.php
@@ -874,25 +874,27 @@ function link_compare($a,$b) {
if(! function_exists('prepare_body')) {
function prepare_body($item,$attach = false) {
+ call_hooks('prepare_body_init', $item);
+
$cache = get_config('system','itemcache');
if (($cache != '')) {
- $cachefile = $cache."/".$item["guid"]."-".strtotime($item["edited"])."-".$attach;
- if (file_exists($cachefile))
- return(file_get_contents($cachefile));
- }
-
- call_hooks('prepare_body_init', $item);
+ $cachefile = $cache."/".$item["guid"]."-".strtotime($item["edited"])."-".$attach."-".hash("crc32", $item['body']);
- $s = prepare_text($item['body']);
+ if (file_exists($cachefile))
+ $s = file_get_contents($cachefile);
+ else {
+ $s = prepare_text($item['body']);
+ file_put_contents($cachefile, $s);
+ }
+ } else
+ $s = prepare_text($item['body']);
$prep_arr = array('item' => $item, 'html' => $s);
call_hooks('prepare_body', $prep_arr);
$s = $prep_arr['html'];
if(! $attach) {
- if ($cache != '')
- file_put_contents($cachefile, $s);
return $s;
}
@@ -925,13 +927,9 @@ function prepare_body($item,$attach = false) {
$s .= '<div class="clear"></div></div>';
}
-
$prep_arr = array('item' => $item, 'html' => $s);
call_hooks('prepare_body_final', $prep_arr);
- if ($cache != '')
- file_put_contents($cachefile, $prep_arr['html']);
-
return $prep_arr['html'];
}}