if (!$deleted AND !$dontcache) {
// Store the fresh generated item into the cache
- $cachefile = get_cachefile(urlencode($arr["guid"])."-".hash("md5", $arr['body']));
-
- 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);
- }
+ put_item_in_cache($arr);
$r = q('SELECT * FROM `item` WHERE id = %d', intval($current_post));
if (count($r) == 1) {
}}
+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.
// If attach is true, also add icons for item attachments
require_once('include/tags.php');
require_once('include/files.php');
require_once('include/threads.php');
+require_once('include/text.php');
function item_post(&$a) {
if(count($r)) {
$post_id = $r[0]['id'];
logger('mod_item: saved item ' . $post_id);
- add_thread($post_id);
// update filetags in pconfig
file_tag_update_pconfig($uid,$categories_old,$categories_new,'category');
// Store the fresh generated item into the cache
- $cachefile = get_cachefile(urlencode($datarray["guid"])."-".hash("md5", $datarray['body']));
-
- 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);
- }
+ put_item_in_cache($datarray);
if($parent) {
dbesc(datetime_convert()),
intval($parent)
);
- update_thread($parent);
+ if ($post_id != $parent)
+ update_thread($parent);
$datarray['id'] = $post_id;
$datarray['plink'] = $a->get_baseurl().'/display/'.urlencode($datarray['guid']);
create_tags_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
// e.g. dreamhost. We used to start delivery to our native delivery agents in the background