Relocated the cache code.
This commit is contained in:
parent
2dc5f1aefc
commit
1a75503b1c
|
@ -1480,16 +1480,7 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
|
||||||
if (!$deleted AND !$dontcache) {
|
if (!$deleted AND !$dontcache) {
|
||||||
|
|
||||||
// Store the fresh generated item into the cache
|
// Store the fresh generated item into the cache
|
||||||
$cachefile = get_cachefile(urlencode($arr["guid"])."-".hash("md5", $arr['body']));
|
put_item_in_cache($arr);
|
||||||
|
|
||||||
if (($cachefile != '') AND !file_exists($cachefile)) {
|
|
||||||
$s = prepare_text($arr['body']);
|
|
||||||
$a = get_app();
|
|
||||||
$stamp1 = microtime(true);
|
|
||||||
file_put_contents($cachefile, $s);
|
|
||||||
$a->save_timestamp($stamp1, "file");
|
|
||||||
logger('item_store: put item '.$current_post.' into cachefile '.$cachefile);
|
|
||||||
}
|
|
||||||
|
|
||||||
$r = q('SELECT * FROM `item` WHERE id = %d', intval($current_post));
|
$r = q('SELECT * FROM `item` WHERE id = %d', intval($current_post));
|
||||||
if (count($r) == 1) {
|
if (count($r) == 1) {
|
||||||
|
|
|
@ -1281,6 +1281,18 @@ function redir_private_images($a, &$item) {
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
function put_item_in_cache($item) {
|
||||||
|
$cachefile = get_cachefile(urlencode($item["guid"])."-".hash("md5", $item['body']));
|
||||||
|
|
||||||
|
if (($cachefile != '') AND !file_exists($cachefile)) {
|
||||||
|
$s = prepare_text($item['body']);
|
||||||
|
$a = get_app();
|
||||||
|
$stamp1 = microtime(true);
|
||||||
|
file_put_contents($cachefile, $s);
|
||||||
|
$a->save_timestamp($stamp1, "file");
|
||||||
|
logger('put item '.$item["guid"].' into cachefile '.$cachefile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Given an item array, convert the body element from bbcode to html and add smilie icons.
|
// Given an item array, convert the body element from bbcode to html and add smilie icons.
|
||||||
// If attach is true, also add icons for item attachments
|
// If attach is true, also add icons for item attachments
|
||||||
|
|
19
mod/item.php
19
mod/item.php
|
@ -22,6 +22,7 @@ require_once('library/langdet/Text/LanguageDetect.php');
|
||||||
require_once('include/tags.php');
|
require_once('include/tags.php');
|
||||||
require_once('include/files.php');
|
require_once('include/files.php');
|
||||||
require_once('include/threads.php');
|
require_once('include/threads.php');
|
||||||
|
require_once('include/text.php');
|
||||||
|
|
||||||
function item_post(&$a) {
|
function item_post(&$a) {
|
||||||
|
|
||||||
|
@ -824,21 +825,12 @@ function item_post(&$a) {
|
||||||
if(count($r)) {
|
if(count($r)) {
|
||||||
$post_id = $r[0]['id'];
|
$post_id = $r[0]['id'];
|
||||||
logger('mod_item: saved item ' . $post_id);
|
logger('mod_item: saved item ' . $post_id);
|
||||||
add_thread($post_id);
|
|
||||||
|
|
||||||
// update filetags in pconfig
|
// update filetags in pconfig
|
||||||
file_tag_update_pconfig($uid,$categories_old,$categories_new,'category');
|
file_tag_update_pconfig($uid,$categories_old,$categories_new,'category');
|
||||||
|
|
||||||
// Store the fresh generated item into the cache
|
// Store the fresh generated item into the cache
|
||||||
$cachefile = get_cachefile(urlencode($datarray["guid"])."-".hash("md5", $datarray['body']));
|
put_item_in_cache($datarray);
|
||||||
|
|
||||||
if (($cachefile != '') AND !file_exists($cachefile)) {
|
|
||||||
$s = prepare_text($datarray['body']);
|
|
||||||
$stamp1 = microtime(true);
|
|
||||||
file_put_contents($cachefile, $s);
|
|
||||||
$a->save_timestamp($stamp1, "file");
|
|
||||||
logger('mod_item: put item '.$r[0]['id'].' into cachefile '.$cachefile);
|
|
||||||
}
|
|
||||||
|
|
||||||
if($parent) {
|
if($parent) {
|
||||||
|
|
||||||
|
@ -947,7 +939,8 @@ function item_post(&$a) {
|
||||||
dbesc(datetime_convert()),
|
dbesc(datetime_convert()),
|
||||||
intval($parent)
|
intval($parent)
|
||||||
);
|
);
|
||||||
update_thread($parent);
|
if ($post_id != $parent)
|
||||||
|
update_thread($parent);
|
||||||
|
|
||||||
$datarray['id'] = $post_id;
|
$datarray['id'] = $post_id;
|
||||||
$datarray['plink'] = $a->get_baseurl().'/display/'.urlencode($datarray['guid']);
|
$datarray['plink'] = $a->get_baseurl().'/display/'.urlencode($datarray['guid']);
|
||||||
|
@ -990,7 +983,9 @@ function item_post(&$a) {
|
||||||
|
|
||||||
create_tags_from_item($post_id);
|
create_tags_from_item($post_id);
|
||||||
create_files_from_item($post_id);
|
create_files_from_item($post_id);
|
||||||
update_thread($post_id);
|
|
||||||
|
if ($post_id == $parent)
|
||||||
|
add_thread($post_id);
|
||||||
|
|
||||||
// This is a real juggling act on shared hosting services which kill your processes
|
// This is a real juggling act on shared hosting services which kill your processes
|
||||||
// e.g. dreamhost. We used to start delivery to our native delivery agents in the background
|
// e.g. dreamhost. We used to start delivery to our native delivery agents in the background
|
||||||
|
|
Loading…
Reference in a new issue