From: Michael Vogel Date: Sun, 13 Jan 2013 08:37:15 +0000 (+0100) Subject: Mentions are now displayed much faster. Attention: The related database update can... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=8cef0fa80d63e72fe0adb14aaa43eb9c23702a49;p=friendica.git Mentions are now displayed much faster. Attention: The related database update can last more than one minute. bbcode: The generated HTML is now cleaned up every time (using the DOM) since it happened that bad html broke the network page. --- diff --git a/boot.php b/boot.php index bf0f86eaee..7bd0fec4db 100644 --- a/boot.php +++ b/boot.php @@ -14,7 +14,7 @@ require_once('include/features.php'); define ( 'FRIENDICA_PLATFORM', 'Friendica'); define ( 'FRIENDICA_VERSION', '3.1.1572' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); -define ( 'DB_UPDATE_VERSION', 1158 ); +define ( 'DB_UPDATE_VERSION', 1159 ); define ( 'EOL', "
\r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); diff --git a/database.sql b/database.sql index bc3c1aabd1..f7fdfa3d9e 100644 --- a/database.sql +++ b/database.sql @@ -546,6 +546,7 @@ CREATE TABLE IF NOT EXISTS `item` ( `deleted` tinyint(1) NOT NULL DEFAULT '0', `origin` tinyint(1) NOT NULL DEFAULT '0', `forum_mode` tinyint(1) NOT NULL DEFAULT '0', + `mention` tinyint(1) NOT NULL DEFAULT '0', `last-child` tinyint(1) unsigned NOT NULL DEFAULT '1', PRIMARY KEY (`id`), KEY `uri` (`uri`), @@ -575,6 +576,7 @@ CREATE TABLE IF NOT EXISTS `item` ( KEY `uid_commented` (`uid`, `commented`), KEY `uid_created` (`uid`, `created`), KEY `uid_unseen` (`uid`, `unseen`), + KEY `mention` (`mention`), FULLTEXT KEY `title` (`title`), FULLTEXT KEY `body` (`body`), FULLTEXT KEY `allow_cid` (`allow_cid`), diff --git a/include/api.php b/include/api.php index 2c5ddc626f..1b33378b0a 100644 --- a/include/api.php +++ b/include/api.php @@ -1040,18 +1040,23 @@ $myurl = str_replace(array('www.','.'),array('','\\.'),$myurl); $diasp_url = str_replace('/profile/','/u/',$myurl); - if (get_config('system','use_fulltext_engine')) - $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where (MATCH(`author-link`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(`tag`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode))) ", - dbesc(protect_sprintf($myurl)), - dbesc(protect_sprintf($myurl)), - dbesc(protect_sprintf($diasp_url)) - ); - else - $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where ( `author-link` like '%s' or `tag` like '%s' or tag like '%s' )) ", - dbesc(protect_sprintf('%' . $myurl)), - dbesc(protect_sprintf('%' . $myurl . ']%')), - dbesc(protect_sprintf('%' . $diasp_url . ']%')) - ); + /*if (get_config('system','use_fulltext_engine')) + $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where (MATCH(`author-link`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(`tag`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode))) ", + dbesc(protect_sprintf($myurl)), + dbesc(protect_sprintf($myurl)), + dbesc(protect_sprintf($diasp_url)) + ); + else + $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where ( `author-link` like '%s' or `tag` like '%s' or tag like '%s' )) ", + dbesc(protect_sprintf('%' . $myurl)), + dbesc(protect_sprintf('%' . $myurl . ']%')), + dbesc(protect_sprintf('%' . $diasp_url . ']%')) + );*/ + + $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where `author-link` IN ('https://%s', 'http://%s') OR `mention`)", + dbesc(protect_sprintf($myurl)), + dbesc(protect_sprintf($myurl)) + ); if ($max_id > 0) $sql_extra .= ' AND `item`.`id` <= '.intval($max_id); diff --git a/include/bbcode.php b/include/bbcode.php index 08edc19340..a7cfa079d1 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -603,7 +603,8 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { // Clean up the HTML by loading and saving the HTML with the DOM // Only do it when it has to be done - for performance reasons - if (!$tryoembed) { + // Update: Now it is done every time - since bad structured html can break a whole page + //if (!$tryoembed) { $doc = new DOMDocument(); $doc->preserveWhiteSpace = false; @@ -618,7 +619,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { $Text = str_replace('
','', $Text); $Text = mb_convert_encoding($Text, "UTF-8", 'HTML-ENTITIES'); - } + //} call_hooks('bbcode',$Text); diff --git a/include/tags.php b/include/tags.php index 384d6581fa..aabe40d1c6 100644 --- a/include/tags.php +++ b/include/tags.php @@ -20,7 +20,7 @@ function create_tags_from_item($itemid) { $searchpath = $a->get_baseurl()."/search?tag="; - $messages = q("SELECT `uri`, `uid`, `id`, `deleted`, `title`, `body`, `tag` FROM `item` WHERE `id` = %d LIMIT 1", intval($itemid)); + $messages = q("SELECT `uri`, `uid`, `id`, `created`, `edited`, `commented`, `received`, `changed`, `deleted`, `title`, `body`, `tag` FROM `item` WHERE `id` = %d LIMIT 1", intval($itemid)); if (!$messages) return; @@ -58,8 +58,9 @@ function create_tags_from_item($itemid) { } foreach ($tags as $tag=>$link) - $r = q("INSERT INTO `tag` (`iid`, `tag`, `link`) VALUES (%d, '%s', '%s')", - intval($itemid), dbesc($tag), dbesc($link)); + $r = q("INSERT INTO `tag` (`iid`, `tag`, `link`, `created`, `edited`, `commented`, `received`, `changed`) VALUES (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s')", + intval($itemid), dbesc($tag), dbesc($link), dbesc($message["created"]), + dbesc($message["edited"]), dbesc($message["commented"]), dbesc($message["received"]), dbesc($message["changed"])); } function create_tags_from_itemuri($itemuri, $uid) { diff --git a/mod/item.php b/mod/item.php index 8399b796dc..7096239b0f 100644 --- a/mod/item.php +++ b/mod/item.php @@ -19,6 +19,7 @@ require_once('include/crypto.php'); require_once('include/enotify.php'); require_once('include/email.php'); require_once('library/langdet/Text/LanguageDetect.php'); +require_once('include/tags.php'); function item_post(&$a) { @@ -685,6 +686,7 @@ function item_post(&$a) { intval($post_id), intval($profile_uid) ); + create_tags_from_itemuri($post_id, $profile_uid); // update filetags in pconfig file_tag_update_pconfig($uid,$categories_old,$categories_new,'category'); @@ -750,6 +752,7 @@ function item_post(&$a) { if(count($r)) { $post_id = $r[0]['id']; logger('mod_item: saved item ' . $post_id); + create_tags_from_item($post_id); // update filetags in pconfig file_tag_update_pconfig($uid,$categories_old,$categories_new,'category'); diff --git a/mod/network.php b/mod/network.php index 2524ae0634..ecef7c1dfb 100644 --- a/mod/network.php +++ b/mod/network.php @@ -674,8 +674,10 @@ function network_content(&$a, $update = 0) { $myurl = substr($myurl,strpos($myurl,'://')+3); $myurl = str_replace('www.','',$myurl); $diasp_url = str_replace('/profile/','/u/',$myurl); - if (get_config('system','use_fulltext_engine')) + /*if (get_config('system','use_fulltext_engine')) $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where (MATCH(`author-link`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(`tag`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode))) ", + //$sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where (`author-link` IN ('https://%s', 'http://%s') OR MATCH(`tag`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode))) ", + //$sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where `author-link` IN ('https://%s', 'http://%s') OR `mention`)", dbesc(protect_sprintf($myurl)), dbesc(protect_sprintf($myurl)), dbesc(protect_sprintf($diasp_url)) @@ -685,8 +687,12 @@ function network_content(&$a, $update = 0) { dbesc(protect_sprintf('%' . $myurl)), dbesc(protect_sprintf('%' . $myurl . ']%')), dbesc(protect_sprintf('%' . $diasp_url . ']%')) - ); + );*/ + $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where `author-link` IN ('https://%s', 'http://%s') OR `mention`)", + dbesc(protect_sprintf($myurl)), + dbesc(protect_sprintf($myurl)) + ); } if($update) { diff --git a/mod/search.php b/mod/search.php index 6694fbc780..aedd639403 100644 --- a/mod/search.php +++ b/mod/search.php @@ -124,6 +124,9 @@ function search_content(&$a) { if(! $search) return $o; + if (get_config('system','only_tag_search')) + $tag = true; + if (get_config('system','use_fulltext_engine')) { if($tag) $sql_extra = sprintf(" AND MATCH (`item`.`tag`) AGAINST ('".'"%s"'."' in boolean mode) ", '#'.dbesc(protect_sprintf($search))); diff --git a/update.php b/update.php index 7308a6acf7..04ae451a1c 100644 --- a/update.php +++ b/update.php @@ -1,6 +1,6 @@