aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
authorMichael Vogel <icarus@dabo.de>2012-05-26 03:21:07 +0200
committerMichael Vogel <icarus@dabo.de>2012-05-26 03:21:07 +0200
commit49512105082dde72553f4250e6284920612cc6b8 (patch)
treee6222e7ca809b116af44d006218271bc36b5c009 /mod
parenta71e3134bf7250b60cafd1e51098eea70c3459de (diff)
downloadvolse-hubzilla-49512105082dde72553f4250e6284920612cc6b8.tar.gz
volse-hubzilla-49512105082dde72553f4250e6284920612cc6b8.tar.bz2
volse-hubzilla-49512105082dde72553f4250e6284920612cc6b8.zip
Speed optimisation by enabling the posibility of the MySQL fulltext engine
Diffstat (limited to 'mod')
-rw-r--r--mod/network.php18
-rw-r--r--mod/search.php16
2 files changed, 24 insertions, 10 deletions
diff --git a/mod/network.php b/mod/network.php
index c6f683b93..f54d055d3 100644
--- a/mod/network.php
+++ b/mod/network.php
@@ -416,11 +416,19 @@ function network_content(&$a, $update = 0) {
$myurl = substr($myurl,strpos($myurl,'://')+3);
$myurl = str_replace(array('www.','.'),array('','\\.'),$myurl);
$diasp_url = str_replace('/profile/','/u/',$myurl);
- $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 . '\\]%'))
+ );
+
}
diff --git a/mod/search.php b/mod/search.php
index 3e6bf68aa..ac5134696 100644
--- a/mod/search.php
+++ b/mod/search.php
@@ -109,11 +109,17 @@ function search_content(&$a) {
if(! $search)
return $o;
- if($tag)
- $sql_extra = sprintf(" AND `item`.`tag` REGEXP '%s' ", dbesc('\\]' . preg_quote($search) . '\\['));
- else
- $sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(preg_quote($search)));
-
+ if (get_config('system','use_fulltext_engine')) {
+ if($tag)
+ $sql_extra = sprintf(" AND MATCH (`item`.`tag`) AGAINST ('".'"%s"'."' in boolean mode) ", '#'.preg_quote($search));
+ else
+ $sql_extra = sprintf(" AND MATCH (`item`.`body`) AGAINST ('".'"%s"'."' in boolean mode) ", dbesc(preg_quote($search)));
+ } else {
+ if($tag)
+ $sql_extra = sprintf(" AND `item`.`tag` REGEXP '%s' ", dbesc('\\]' . preg_quote($search) . '\\['));
+ else
+ $sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(preg_quote($search)));
+ }