From c90272e2ae52ecab496c6aab068a485b8b22e19a Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Wed, 20 Feb 2013 21:47:36 +0100 Subject: [PATCH] supressing warning when importing items. Speeding up community. Changed query for the search. --- include/items.php | 16 +++++++++------- mod/community.php | 2 +- mod/search.php | 10 +++++++--- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/include/items.php b/include/items.php index 46eafdc25b..b7be27932f 100755 --- a/include/items.php +++ b/include/items.php @@ -835,14 +835,16 @@ function get_atom_elements($feed,$item) { // Search for ostatus conversation url $links = $item->feed->data["child"][SIMPLEPIE_NAMESPACE_ATOM_10]["feed"][0]["child"][SIMPLEPIE_NAMESPACE_ATOM_10]["entry"][0]["child"]["http://www.w3.org/2005/Atom"]["link"]; - foreach ($links as $link) { - $conversation = array_shift($link["attribs"]); + if (is_array($links)) { + foreach ($links as $link) { + $conversation = array_shift($link["attribs"]); - if ($conversation["rel"] == "ostatus:conversation") { - $res["ostatus_conversation"] = $conversation["href"]; - logger('get_atom_elements: found conversation url '.$res["ostatus_conversation"]); - } - }; + if ($conversation["rel"] == "ostatus:conversation") { + $res["ostatus_conversation"] = $conversation["href"]; + logger('get_atom_elements: found conversation url '.$res["ostatus_conversation"]); + } + }; + } $arr = array('feed' => $feed, 'item' => $item, 'result' => $res); diff --git a/mod/community.php b/mod/community.php index e267447e41..27a9e21941 100644 --- a/mod/community.php +++ b/mod/community.php @@ -70,7 +70,7 @@ function community_content(&$a, $update = 0) { `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`, `user`.`nickname`, `user`.`hidewall` - FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` + FROM `item` FORCE INDEX (`received`) 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` = '' diff --git a/mod/search.php b/mod/search.php index 93feebdd9a..f7d235d458 100644 --- a/mod/search.php +++ b/mod/search.php @@ -140,9 +140,13 @@ 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", + // 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 = "`term` LEFT JOIN `item` ON `item`.`id` = `term`.`oid` AND `item`.`uid` = `term`.`uid` "; + $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))); @@ -178,7 +182,7 @@ 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`,