diff options
author | friendica <info@friendica.com> | 2013-02-09 03:40:56 -0800 |
---|---|---|
committer | friendica <info@friendica.com> | 2013-02-09 03:40:56 -0800 |
commit | d8c667288ecf6cd358751df250f2b45e476ff40c (patch) | |
tree | eceb0931c382d9866975f91d593c95d94d214418 /include/conversation.php | |
parent | 6d73e5c0a6b3bd8f60dbd1a71f77e6dd01028a7e (diff) | |
download | volse-hubzilla-d8c667288ecf6cd358751df250f2b45e476ff40c.tar.gz volse-hubzilla-d8c667288ecf6cd358751df250f2b45e476ff40c.tar.bz2 volse-hubzilla-d8c667288ecf6cd358751df250f2b45e476ff40c.zip |
this seems to cut load times in half
Diffstat (limited to 'include/conversation.php')
-rw-r--r-- | include/conversation.php | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/include/conversation.php b/include/conversation.php index 12d5c7160..4758721a5 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -300,17 +300,21 @@ function localize_item(&$item){ */ $matches = null; - if(preg_match_all('/@\[url=(.*?)\]/is',$item['body'],$matches,PREG_SET_ORDER)) { - foreach($matches as $mtch) { - if(! strpos($mtch[1],'zid=')) - $item['body'] = str_replace($mtch[0],'@[url=' . zid($mtch[1]). ']',$item['body']); + if(strpos($item['body'],'[url') !== false) { + if(preg_match_all('/@\[url=(.*?)\]/is',$item['body'],$matches,PREG_SET_ORDER)) { + foreach($matches as $mtch) { + if(! strpos($mtch[1],'zid=')) + $item['body'] = str_replace($mtch[0],'@[url=' . zid($mtch[1]). ']',$item['body']); + } } } - // add zid's to public images - if(preg_match_all('/\[url=(.*?)\/photos\/(.*?)\/image\/(.*?)\]\[img(.*?)\]h(.*?)\[\/img\]\[\/url\]/is',$item['body'],$matches,PREG_SET_ORDER)) { - foreach($matches as $mtch) { + if(strpos($item['body'],'[img') !== false) { + // add zid's to public images + if(preg_match_all('/\[url=(.*?)\/photos\/(.*?)\/image\/(.*?)\]\[img(.*?)\]h(.*?)\[\/img\]\[\/url\]/is',$item['body'],$matches,PREG_SET_ORDER)) { + foreach($matches as $mtch) { $item['body'] = str_replace($mtch[0],'[url=' . zid( $mtch[1] . '/photos/' . $mtch[2] . '/image/' . $mtch[3]) . '][img' . $mtch[4] . ']h' . $mtch[5] . '[/img][/url]',$item['body']); + } } } @@ -378,6 +382,9 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional') { $previewing = (($preview) ? ' preview ' : ''); if($mode === 'network') { + + $t1 = dba_timer(); + $profile_owner = local_user(); $page_writeable = true; @@ -661,33 +668,33 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional') { if(feature_enabled($profile_owner,'dislike')) like_puller($a,$item,$dlike,'dislike'); - // Only add what is visible - if($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) { - continue; - } if(! visible_activity($item)) { continue; } - - - $item['pagedrop'] = $page_dropping; - - if($item['id'] == $item['parent']) { +// $tx1 = dba_timer(); $item_object = new Item($item); $conv->add_thread($item_object); +// $tx2 = dba_timer(); +// if($mode === 'network') +// profiler($tx1,$tx2,'add thread ' . $item['id']); } } - + $t2 = dba_timer(); $threads = $conv->get_template_data($alike, $dlike); if(!$threads) { logger('[ERROR] conversation : Failed to get template data.', LOGGER_DEBUG); $threads = array(); } - + $t3 = dba_timer(); + if($mode === 'network') { + profiler($t1,$t2,'Conversation prepare'); + profiler($t2,$t3,'Conversation get_template'); + } + } } @@ -722,6 +729,11 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional') { '$dropping' => ($page_dropping?t('Delete Selected Items'):False), )); + if($mode === 'network') { + $t4 = dba_timer(); + profiler($t3,$t4,'conversation template'); + } + if($page_mode === 'preview') logger('preview: ' . $o); |