Browse Source

Add some analysing stuff, rendered value is written now more often

pull/2253/head
Michael Vogel 5 years ago
parent
commit
c4ba035ee3
7 changed files with 52 additions and 15 deletions
  1. +27
    -1
      boot.php
  2. +5
    -5
      include/conversation.php
  3. +1
    -1
      include/cron.php
  4. +5
    -1
      include/diaspora.php
  5. +3
    -2
      include/items.php
  6. +6
    -2
      include/text.php
  7. +5
    -3
      include/threads.php

+ 27
- 1
boot.php View File

@ -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) {


+ 5
- 5
include/conversation.php View File

@ -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


+ 1
- 1
include/cron.php View File

@ -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) {


+ 5
- 1
include/diaspora.php View File

@ -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']);
}


+ 3
- 2
include/items.php View File

@ -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] ";
}
}


+ 6
- 2
include/text.php View File

@ -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 .= "<hr>*********************************<hr>".$test;
$prep_arr = array('item' => $item, 'html' => $s, 'preview' => $preview);
call_hooks('prepare_body', $prep_arr);
$s = $prep_arr['html'];


+ 5
- 3
include/threads.php View File

@ -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);


Loading…
Cancel
Save