X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fsearch.php;h=ebb7dc70d261c053421f34468768c71c56cd8a99;hb=7ab366b9c3653160dbe68fe2d096e4174547ff84;hp=b368deb49d91b63737014ac7545eaa64900a3ecc;hpb=2350aa54ebae23394d9e36445247dcd2235e7173;p=friendica.git diff --git a/mod/search.php b/mod/search.php index b368deb49d..ebb7dc70d2 100644 --- a/mod/search.php +++ b/mod/search.php @@ -140,9 +140,14 @@ function search_content(&$a) { }*/ if($tag) { - $sql_extra = sprintf(" AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d", + //$sql_extra = sprintf(" AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d", + $sql_extra = sprintf(" AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d group by `item`.`uri` ", dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG)); $sql_table = "`term` LEFT JOIN `item` ON `item`.`id` = `term`.`oid` AND `item`.`uid` = `term`.`uid` "; + + //$sql_extra = sprintf(" AND EXISTS (SELECT * FROM `term` WHERE `item`.`id` = `term`.`oid` AND `item`.`uid` = `term`.`uid` AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d) GROUP BY `item`.`uri` ", + // dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG)); + //$sql_table = "`item` FORCE INDEX (`uri`) "; } else { if (get_config('system','use_fulltext_engine')) { $sql_extra = sprintf(" AND MATCH (`item`.`body`, `item`.`title`) AGAINST ('%s' in boolean mode) ", dbesc(protect_sprintf($search))); @@ -162,7 +167,7 @@ function search_content(&$a) { FROM $sql_table LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` LEFT JOIN `user` ON `user`.`uid` = `item`.`uid` WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 AND (( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `item`.`private` = 0 AND `user`.`hidewall` = 0) - OR `item`.`uid` = %d ) + OR ( `item`.`uid` = %d )) AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 $sql_extra ", intval(local_user()) @@ -178,16 +183,16 @@ function search_content(&$a) { } } - $r = q("SELECT distinct(`item`.`uri`), `item`.*, `item`.`id` AS `item_id`, + $r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`, `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`, - `user`.`nickname` + `user`.`nickname`, `user`.`uid`, `user`.`hidewall` FROM $sql_table LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` LEFT JOIN `user` ON `user`.`uid` = `item`.`uid` WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 AND (( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `item`.`private` = 0 AND `user`.`hidewall` = 0 ) - OR `item`.`uid` = %d ) + OR ( `item`.`uid` = %d )) AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 $sql_extra ORDER BY `received` DESC LIMIT %d , %d ",