diff --git a/boot.php b/boot.php index 7d8c7040d..ae98e9240 100644 --- a/boot.php +++ b/boot.php @@ -467,6 +467,7 @@ class App { public $is_tablet; public $is_friendica_app; public $performance = array(); + public $callstack = array(); public $nav_sel; @@ -552,7 +553,15 @@ class App { $this->performance["rendering"] = 0; $this->performance["parser"] = 0; $this->performance["marktime"] = 0; - $this->performance["markstart"] = microtime(true); + + $this->performance["file"] = 0; + $this->performance["file"] = 0; + + $this->callstack["database"] = array(); + $this->callstack["network"] = array(); + $this->callstack["file"] = array(); + $this->callstack["rendering"] = array(); + $this->callstack["parser"] = array(); $this->config = array(); $this->page = array(); @@ -1016,6 +1025,23 @@ class App { $this->performance[$value] += (float)$duration; $this->performance["marktime"] += (float)$duration; + + // Trace the different functions with their timestamps + $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 5); + + array_shift($trace); + + $function = array(); + foreach ($trace AS $func) + $function[] = $func["function"]; + + $function = implode(", ", $function); + + //$last = array_pop($trace); + //$function = $last["function"]; + + $this->callstack[$value][$function] += (float)$duration; + } function mark_timestamp($mark) { diff --git a/include/conversation.php b/include/conversation.php index 7eae1e052..d8c5e4461 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -315,11 +315,11 @@ function localize_item(&$item){ } // add zrl's to public images - $photo_pattern = "/\[url=(.*?)\/photos\/(.*?)\/image\/(.*?)\]\[img(.*?)\]h(.*?)\[\/img\]\[\/url\]/is"; - if(preg_match($photo_pattern,$item['body'])) { - $photo_replace = '[url=' . zrl('$1' . '/photos/' . '$2' . '/image/' . '$3' ,true) . '][img' . '$4' . ']h' . '$5' . '[/img][/url]'; - $item['body'] = bb_tag_preg_replace($photo_pattern, $photo_replace, 'url', $item['body']); - } +// $photo_pattern = "/\[url=(.*?)\/photos\/(.*?)\/image\/(.*?)\]\[img(.*?)\]h(.*?)\[\/img\]\[\/url\]/is"; +// if(preg_match($photo_pattern,$item['body'])) { +// $photo_replace = '[url=' . zrl('$1' . '/photos/' . '$2' . '/image/' . '$3' ,true) . '][img' . '$4' . ']h' . '$5' . '[/img][/url]'; +// $item['body'] = bb_tag_preg_replace($photo_pattern, $photo_replace, 'url', $item['body']); +// } // add sparkle links to appropriate permalinks diff --git a/include/cron.php b/include/cron.php index 09d141702..ed7edc699 100644 --- a/include/cron.php +++ b/include/cron.php @@ -230,7 +230,7 @@ function cron_run(&$argv, &$argc){ // Repair missing Diaspora settings $r = q("SELECT `id`, `url` FROM `contact` - WHERE `uid` > 0 AND `network` = '%s' AND (`batch` = '' OR `notify` = '' OR `poll` = '' OR pubkey = '') + WHERE `network` = '%s' AND (`batch` = '' OR `notify` = '' OR `poll` = '' OR pubkey = '') ORDER BY RAND() LIMIT 50", dbesc(NETWORK_DIASPORA)); if ($r) { foreach ($r AS $contact) { diff --git a/include/diaspora.php b/include/diaspora.php index 1cf8897af..f03486fc2 100644 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -1973,11 +1973,15 @@ function diaspora_photo($importer,$xml,$msg,$attempt=1) { array($remote_photo_name, 'scaled_full_' . $remote_photo_name)); if(strpos($parent_item['body'],$link_text) === false) { + + $parent_item['body'] = $link_text . $parent_item['body']; + $r = q("UPDATE `item` SET `body` = '%s', `visible` = 1 WHERE `id` = %d AND `uid` = %d", - dbesc($link_text . $parent_item['body']), + dbesc($parent_item['body']), intval($parent_item['id']), intval($parent_item['uid']) ); + put_item_in_cache($parent_item, true); update_thread($parent_item['id']); } diff --git a/include/items.php b/include/items.php index 549027671..62526d448 100644 --- a/include/items.php +++ b/include/items.php @@ -955,8 +955,9 @@ function add_page_info_data($data) { $a = get_app(); $hashtags = "\n"; foreach ($data["keywords"] AS $keyword) { - $hashtag = str_replace(array(" ", "+", "/", ".", "#", "'"), - array("","", "", "", "", ""), $keyword); + /// @todo make a positive list of allowed characters + $hashtag = str_replace(array(" ", "+", "/", ".", "#", "'", "’", "`", "(", ")", "„", "“"), + array("","", "", "", "", "", "", "", "", "", "", ""), $keyword); $hashtags .= "#[url=".$a->get_baseurl()."/search?tag=".rawurlencode($hashtag)."]".$hashtag."[/url] "; } } diff --git a/include/text.php b/include/text.php index 1b03c39d2..3f4fe07d6 100644 --- a/include/text.php +++ b/include/text.php @@ -20,10 +20,10 @@ function replace_macros($s,$r) { $stamp1 = microtime(true); $a = get_app(); - + // pass $baseurl to all templates $r['$baseurl'] = z_root(); - + $t = $a->template_engine(); try { @@ -1415,9 +1415,13 @@ function prepare_body(&$item,$attach = false, $preview = false) { $item['hashtags'] = $hashtags; $item['mentions'] = $mentions; + $test = $item["rendered-html"]; put_item_in_cache($item, true); $s = $item["rendered-html"]; + //if ($test != $s) + // $s .= "
*********************************
".$test; + $prep_arr = array('item' => $item, 'html' => $s, 'preview' => $preview); call_hooks('prepare_body', $prep_arr); $s = $prep_arr['html']; diff --git a/include/threads.php b/include/threads.php index dddcc4cdd..e542295d7 100644 --- a/include/threads.php +++ b/include/threads.php @@ -112,7 +112,7 @@ function update_thread_uri($itemuri, $uid) { function update_thread($itemid, $setmention = false) { $items = q("SELECT `uid`, `guid`, `title`, `body`, `created`, `edited`, `commented`, `received`, `changed`, `wall`, `private`, `pubmail`, `moderated`, `visible`, `spam`, `starred`, `bookmark`, `contact-id`, `gcontact-id`, - `deleted`, `origin`, `forum_mode`, `network` FROM `item` WHERE `id` = %d AND (`parent` = %d OR `parent` = 0) LIMIT 1", intval($itemid), intval($itemid)); + `deleted`, `origin`, `forum_mode`, `network`, `rendered-html`, `rendered-hash` FROM `item` WHERE `id` = %d AND (`parent` = %d OR `parent` = 0) LIMIT 1", intval($itemid), intval($itemid)); if (!$items) return; @@ -125,7 +125,7 @@ function update_thread($itemid, $setmention = false) { $sql = ""; foreach ($item AS $field => $data) - if (!in_array($field, array("guid", "title", "body"))) { + if (!in_array($field, array("guid", "title", "body", "rendered-html", "rendered-hash"))) { if ($sql != "") $sql .= ", "; @@ -142,9 +142,11 @@ function update_thread($itemid, $setmention = false) { if (!$items) return; - $result = q("UPDATE `item` SET `title` = '%s', `body` = '%s' WHERE `id` = %d", + $result = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `rendered-html` = '%s', `rendered-hash` = '%s' WHERE `id` = %d", dbesc($item["title"]), dbesc($item["body"]), + dbesc($item["rendered-html"]), + dbesc($item["rendered-hash"]), intval($items[0]["id"]) ); logger("Updating public shadow for post ".$items[0]["id"]." - guid ".$item["guid"]." Result: ".print_r($result, true), LOGGER_DEBUG);