From: Michael Vogel Date: Sun, 16 Mar 2014 16:12:56 +0000 (+0100) Subject: Even more SQL improvements. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=bbf9378a495106a452b2c6001902b44c7e88fef0;p=friendica.git Even more SQL improvements. --- diff --git a/database.sql b/database.sql index 8480051752..0d45dda106 100644 --- a/database.sql +++ b/database.sql @@ -1202,7 +1202,7 @@ CREATE TABLE IF NOT EXISTS `unique_contacts` ( CREATE TABLE IF NOT EXISTS `thread` ( `iid` int(10) unsigned NOT NULL DEFAULT '0', `uid` int(10) unsigned NOT NULL DEFAULT '0', - `contact-id` int(10) unsigned NOT NULL DEFAULT '0', + `contact-id` int(11) unsigned NOT NULL DEFAULT '0', `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `edited` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `commented` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', @@ -1223,15 +1223,13 @@ CREATE TABLE IF NOT EXISTS `thread` ( `mention` tinyint(1) NOT NULL DEFAULT '0', `network` char(32) NOT NULL, PRIMARY KEY (`iid`), - KEY `uid` (`uid`), - KEY `contact-id` (`contact-id`), KEY `created` (`created`), - KEY `edited` (`edited`), KEY `commented` (`commented`), - KEY `received` (`received`), - KEY `changed` (`changed`), - KEY `network` (`network`), - KEY `visible_deleted_moderated_private_wall_received` (`visible`,`deleted`,`moderated`,`private`,`wall`,`received`), - KEY `uid_visible_deleted_moderated_created` (`uid`,`visible`,`deleted`,`moderated`,`created`), - KEY `uid_visible_deleted_moderated_commented` (`uid`,`visible`,`deleted`,`moderated`,`commented`) + KEY `uid_network_commented` (`uid`,`network`,`commented`), + KEY `uid_network_created` (`uid`,`network`,`created`), + KEY `uid_contactid_commented` (`uid`,`contact-id`,`commented`), + KEY `uid_contactid_created` (`uid`,`contact-id`,`created`), + KEY `wall_private_received` (`wall`,`private`,`received`), + KEY `uid_created` (`uid`,`created`), + KEY `uid_commented` (`uid`,`commented`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; diff --git a/include/api.php b/include/api.php index 0a63a2c049..80f448c268 100644 --- a/include/api.php +++ b/include/api.php @@ -386,7 +386,7 @@ //AND `allow_cid`='' AND `allow_gid`='' AND `deny_cid`='' AND `deny_gid`=''", // count public wall messages - $r = q("SELECT count(*) as `count` FROM `item` force index (uid_type) + $r = q("SELECT count(*) as `count` FROM `item` WHERE `uid` = %d AND `type`='wall'", intval($uinfo[0]['uid']) diff --git a/include/items.php b/include/items.php index 6c438f4639..a1eddb2eeb 100755 --- a/include/items.php +++ b/include/items.php @@ -6,6 +6,7 @@ require_once('include/salmon.php'); require_once('include/crypto.php'); require_once('include/Photo.php'); require_once('include/tags.php'); +require_once('include/files.php'); require_once('include/text.php'); require_once('include/email.php'); require_once('include/ostatus_conversation.php'); @@ -123,22 +124,25 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0) $check_date = datetime_convert('UTC','UTC',$last_update,'Y-m-d H:i:s'); + // AND ( `item`.`edited` > '%s' OR `item`.`changed` > '%s' ) + // dbesc($check_date), + $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `contact`.`name`, `contact`.`network`, `contact`.`photo`, `contact`.`url`, `contact`.`name-date`, `contact`.`uri-date`, `contact`.`avatar-date`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, `contact`.`id` AS `contact-id`, `contact`.`uid` AS `contact-uid`, `sign`.`signed_text`, `sign`.`signature`, `sign`.`signer` - FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`uid` = `item`.`uid` + FROM `item` + INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` + AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 LEFT JOIN `sign` ON `sign`.`iid` = `item`.`id` WHERE `item`.`uid` = %d AND `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`parent` != 0 - AND `item`.`wall` = 1 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 - AND ( `item`.`edited` > '%s' OR `item`.`changed` > '%s' ) + AND `item`.`wall` = 1 AND `item`.`changed` > '%s' $sql_extra ORDER BY `parent` %s, `created` ASC LIMIT 0, 300", intval($owner_id), dbesc($check_date), - dbesc($check_date), dbesc($sort) ); @@ -619,7 +623,7 @@ function get_atom_elements($feed, $item, $contact = array()) { $res['edited'] = unxmlify($rawedited[0]['data']); if((x($res,'edited')) && (! (x($res,'created')))) - $res['created'] = $res['edited']; + $res['created'] = $res['edited']; if(! $res['created']) $res['created'] = $item->get_date('c'); @@ -1161,7 +1165,6 @@ function item_store($arr,$force_parent = false) { if(count($r)) { $current_post = $r[0]['id']; logger('item_store: created item ' . $current_post); - create_tags_from_item($r[0]['id']); // Only check for notifications on start posts if ($arr['parent-uri'] === $arr['uri']) { @@ -1240,7 +1243,6 @@ function item_store($arr,$force_parent = false) { intval($parent_deleted), intval($current_post) ); - create_tags_from_item($current_post); // Complete ostatus threads if ($ostatus_conversation) @@ -1304,17 +1306,20 @@ function item_store($arr,$force_parent = false) { logger('item_store: put item '.$current_post.' into cachefile '.$cachefile); } - $r = q('SELECT * FROM `item` WHERE id = %d', intval($current_post)); - if (count($r) == 1) { - call_hooks('post_remote_end', $r[0]); - } - else { - logger('item_store: new item not found in DB, id ' . $current_post); - } + $r = q('SELECT * FROM `item` WHERE id = %d', intval($current_post)); + if (count($r) == 1) { + call_hooks('post_remote_end', $r[0]); + } else { + logger('item_store: new item not found in DB, id ' . $current_post); + } } + + create_tags_from_item($current_post); + create_files_from_item($current_post); + return $current_post; } - +// return - test function get_item_contact($item,$contacts) { if(! count($contacts) || (! is_array($item))) return false; @@ -1762,7 +1767,7 @@ function edited_timestamp_is_newer($existing, $update) { * thing regardless of feed ordering. This won't be adequate in a fully-threaded * model where comments can have sub-threads. That would require some massive sorting * to get all the feed items into a mostly linear ordering, and might still require - * recursion. + * recursion. */ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) { @@ -2041,6 +2046,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) intval($importer['uid']) ); create_tags_from_itemuri($item['uri'], $importer['uid']); + create_files_from_itemuri($item['uri'], $importer['uid']); update_thread_uri($item['uri'], $importer['uid']); } else { @@ -2053,6 +2059,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) intval($importer['uid']) ); create_tags_from_itemuri($uri, $importer['uid']); + create_files_from_itemuri($uri, $importer['uid']); if($item['last-child']) { // ensure that last-child is set in case the comment that had it just got wiped. q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d ", @@ -2159,11 +2166,12 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) if(datetime_convert('UTC','UTC',$datarray['edited']) < $r[0]['edited']) continue; - $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d", + $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s', `changed` = '%s' WHERE `uri` = '%s' AND `uid` = %d", dbesc($datarray['title']), dbesc($datarray['body']), dbesc($datarray['tag']), dbesc(datetime_convert('UTC','UTC',$datarray['edited'])), + dbesc(datetime_convert()), dbesc($item_id), intval($importer['uid']) ); @@ -2319,11 +2327,12 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) if(datetime_convert('UTC','UTC',$datarray['edited']) < $r[0]['edited']) continue; - $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d", + $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s', `changed` = '%s' WHERE `uri` = '%s' AND `uid` = %d", dbesc($datarray['title']), dbesc($datarray['body']), dbesc($datarray['tag']), dbesc(datetime_convert('UTC','UTC',$datarray['edited'])), + dbesc(datetime_convert()), dbesc($item_id), intval($importer['uid']) ); @@ -2948,6 +2957,7 @@ function local_delivery($importer,$data) { intval($importer['importer_uid']) ); create_tags_from_itemuri($item['uri'], $importer['importer_uid']); + create_files_from_itemuri($item['uri'], $importer['importer_uid']); update_thread_uri($item['uri'], $importer['importer_uid']); } else { @@ -2960,6 +2970,7 @@ function local_delivery($importer,$data) { intval($importer['importer_uid']) ); create_tags_from_itemuri($uri, $importer['importer_uid']); + create_files_from_itemuri($uri, $importer['importer_uid']); update_thread_uri($uri, $importer['importer_uid']); if($item['last-child']) { // ensure that last-child is set in case the comment that had it just got wiped. @@ -3078,11 +3089,12 @@ function local_delivery($importer,$data) { continue; logger('received updated comment' , LOGGER_DEBUG); - $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d", + $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s', `changed` = '%s' WHERE `uri` = '%s' AND `uid` = %d", dbesc($datarray['title']), dbesc($datarray['body']), dbesc($datarray['tag']), dbesc(datetime_convert('UTC','UTC',$datarray['edited'])), + dbesc(datetime_convert()), dbesc($item_id), intval($importer['importer_uid']) ); @@ -3164,9 +3176,10 @@ function local_delivery($importer,$data) { intval($importer['importer_uid']) ); if(count($i) && ! intval($i[0]['blocktags'])) { - q("UPDATE item SET tag = '%s', `edited` = '%s' WHERE id = %d", + q("UPDATE item SET tag = '%s', `edited` = '%s', `changed` = '%s' WHERE id = %d", dbesc($tagp[0]['tag'] . (strlen($tagp[0]['tag']) ? ',' : '') . $newtag), intval($tagp[0]['id']), + dbesc(datetime_convert()), dbesc(datetime_convert()) ); create_tags_from_item($tagp[0]['id']); @@ -3262,11 +3275,12 @@ function local_delivery($importer,$data) { if(datetime_convert('UTC','UTC',$datarray['edited']) < $r[0]['edited']) continue; - $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d", + $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s', `changed` = '%s' WHERE `uri` = '%s' AND `uid` = %d", dbesc($datarray['title']), dbesc($datarray['body']), dbesc($datarray['tag']), dbesc(datetime_convert('UTC','UTC',$datarray['edited'])), + dbesc(datetime_convert()), dbesc($item_id), intval($importer['importer_uid']) ); @@ -3447,11 +3461,12 @@ function local_delivery($importer,$data) { if(datetime_convert('UTC','UTC',$datarray['edited']) < $r[0]['edited']) continue; - $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d", + $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s', `changed` = '%s' WHERE `uri` = '%s' AND `uid` = %d", dbesc($datarray['title']), dbesc($datarray['body']), dbesc($datarray['tag']), dbesc(datetime_convert('UTC','UTC',$datarray['edited'])), + dbesc(datetime_convert()), dbesc($item_id), intval($importer['importer_uid']) ); @@ -3828,11 +3843,11 @@ function atom_entry($item,$type,$author,$owner,$comment = false,$cid = 0) { $mentioned = get_mentions($item); if($mentioned) $o .= $mentioned; - + call_hooks('atom_entry', $o); $o .= '' . "\r\n"; - + return $o; } @@ -4021,7 +4036,7 @@ function item_getfeedattach($item) { } - + function item_expire($uid,$days) { if((! $uid) || ($days < 1)) @@ -4181,6 +4196,7 @@ function drop_item($id,$interactive = true) { intval($item['id']) ); create_tags_from_item($item['id']); + create_files_from_item($item['id']); delete_thread($item['id']); // clean up categories and tags so they don't end up as orphans @@ -4276,6 +4292,7 @@ function drop_item($id,$interactive = true) { intval($item['uid']) ); create_tags_from_item($item['parent-uri'], $item['uid']); + create_files_from_item($item['parent-uri'], $item['uid']); delete_thread_uri($item['parent-uri'], $item['uid']); // ignore the result } diff --git a/mod/display.php b/mod/display.php index 2de3a8a88e..5c6277e34c 100644 --- a/mod/display.php +++ b/mod/display.php @@ -120,32 +120,36 @@ function display_content(&$a, $update = 0) { $sql_extra = item_permissions_sql($a->profile['uid'],$remote_contact,$groups); + // AND `item`.`parent` = ( SELECT `parent` FROM `item` FORCE INDEX (PRIMARY, `uri`) WHERE ( `id` = '%s' OR `uri` = '%s' )) + if($update) { $r = q("SELECT id FROM item WHERE item.uid = %d - AND `item`.`parent` = ( SELECT `parent` FROM `item` FORCE INDEX (PRIMARY, `uri`) WHERE ( `id` = '%s' OR `uri` = '%s' )) + AND `item`.`parent` = (SELECT `parent` FROM `item` WHERE (`id` = '%s' OR `uri` = '%s')) $sql_extra AND unseen = 1", intval($a->profile['uid']), dbesc($item_id), - dbesc($item_id) + dbesc($item_id) ); if(!$r) return ''; } + // AND `item`.`parent` = ( SELECT `parent` FROM `item` FORCE INDEX (PRIMARY, `uri`) WHERE ( `id` = '%s' OR `uri` = '%s' ) + $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, - `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, + `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 - AND `item`.`parent` = ( SELECT `parent` FROM `item` FORCE INDEX (PRIMARY, `uri`) WHERE ( `id` = '%s' OR `uri` = '%s' ) - AND uid = %d ) + AND `item`.`parent` = (SELECT `parent` FROM `item` WHERE (`id` = '%s' OR `uri` = '%s') + AND uid = %d) $sql_extra - ORDER BY `parent` DESC, `gravity` ASC, `id` ASC ", + ORDER BY `parent` DESC, `gravity` ASC, `id` ASC", intval($a->profile['uid']), dbesc($item_id), dbesc($item_id), @@ -162,6 +166,7 @@ function display_content(&$a, $update = 0) { ); if($r) { $item_uri = $r[0]['uri']; + // AND `item`.`parent` = ( SELECT `parent` FROM `item` FORCE INDEX (PRIMARY, `uri`) WHERE `uri` = '%s' AND uid = %d ) $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, @@ -171,7 +176,7 @@ function display_content(&$a, $update = 0) { AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 - AND `item`.`parent` = ( SELECT `parent` FROM `item` FORCE INDEX (PRIMARY, `uri`) WHERE `uri` = '%s' AND uid = %d ) + AND `item`.`parent` = (SELECT `parent` FROM `item` WHERE `uri` = '%s' AND uid = %d) ORDER BY `parent` DESC, `gravity` ASC, `id` ASC ", intval(local_user()), dbesc($item_uri), @@ -184,7 +189,7 @@ function display_content(&$a, $update = 0) { if($r) { if((local_user()) && (local_user() == $a->profile['uid'])) { - q("UPDATE `item` SET `unseen` = 0 + q("UPDATE `item` SET `unseen` = 0 WHERE `parent` = %d AND `unseen` = 1", intval($r[0]['parent']) ); @@ -257,8 +262,8 @@ function display_content(&$a, $update = 0) { if($r[0]['deleted']) { notice( t('Item has been removed.') . EOL ); } - else { - notice( t('Permission denied.') . EOL ); + else { + notice( t('Permission denied.') . EOL ); } } else { diff --git a/mod/item.php b/mod/item.php index 451fcb48c4..7d8492bb21 100644 --- a/mod/item.php +++ b/mod/item.php @@ -20,6 +20,7 @@ require_once('include/enotify.php'); require_once('include/email.php'); require_once('library/langdet/Text/LanguageDetect.php'); require_once('include/tags.php'); +require_once('include/files.php'); require_once('include/threads.php'); function item_post(&$a) { @@ -695,18 +696,17 @@ function item_post(&$a) { if($orig_post) { - $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `attach` = '%s', `file` = '%s', `edited` = '%s' WHERE `id` = %d AND `uid` = %d", + $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `attach` = '%s', `file` = '%s', `edited` = '%s', `changed` = '%s' WHERE `id` = %d AND `uid` = %d", dbesc($datarray['title']), dbesc($datarray['body']), dbesc($datarray['tag']), dbesc($datarray['attach']), dbesc($datarray['file']), dbesc(datetime_convert()), + dbesc(datetime_convert()), intval($post_id), intval($profile_uid) ); - create_tags_from_itemuri($post_id, $profile_uid); - update_thread_uri($post_id, $profile_uid); // update filetags in pconfig file_tag_update_pconfig($uid,$categories_old,$categories_new,'category'); @@ -773,7 +773,6 @@ 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); add_thread($post_id); // update filetags in pconfig @@ -871,7 +870,6 @@ function item_post(&$a) { dbesc(datetime_convert()), intval($post_id) ); - update_thread($post_id); // photo comments turn the corresponding item visible to the profile wall // This way we don't see every picture in your new photo album posted to your wall at once. @@ -939,6 +937,10 @@ function item_post(&$a) { } } + create_tags_from_item($post_id); + create_files_from_item($post_id); + update_thread($post_id); + // This is a real juggling act on shared hosting services which kill your processes // e.g. dreamhost. We used to start delivery to our native delivery agents in the background // and then run our plugin delivery from the foreground. We're now doing plugin delivery first, @@ -946,7 +948,7 @@ function item_post(&$a) { // likely to get killed off. If you end up looking at an /item URL and a blank page, // it's very likely the delivery got killed before all your friends could be notified. // Currently the only realistic fixes are to use a reliable server - which precludes shared hosting, - // or cut back on plugins which do remote deliveries. + // or cut back on plugins which do remote deliveries. proc_run('php', "include/notifier.php", $notify_type, "$post_id"); diff --git a/mod/network.php b/mod/network.php index 9d2f60c478..5b2908f0e9 100644 --- a/mod/network.php +++ b/mod/network.php @@ -1,7 +1,7 @@ profile['profile_uid']) ); - } - else { + } else { + $sql_post_table = ""; if(x($category)) { - $sql_extra .= protect_sprintf(file_tag_file_query('item',$category,'category')); + $sql_post_table = sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ", + dbesc(protect_sprintf($category)), intval(TERM_OBJ_POST), intval(TERM_CATEGORY), intval($a->profile['profile_uid'])); + //$sql_extra .= protect_sprintf(file_tag_file_query('item',$category,'category')); } if($datequery) { @@ -247,7 +249,7 @@ function profile_content(&$a, $update = 0) { if( (! get_config('alt_pager', 'global')) && (! get_pconfig($a->profile['profile_uid'],'system','alt_pager')) ) { $r = q("SELECT COUNT(*) AS `total` FROM `thread` INNER JOIN `item` ON `item`.`id` = `thread`.`iid` - INNER JOIN `contact` ON `contact`.`id` = `thread`.`contact-id` + $sql_post_table INNER JOIN `contact` ON `contact`.`id` = `thread`.`contact-id` AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 WHERE `thread`.`uid` = %d AND `thread`.`visible` = 1 AND `thread`.`deleted` = 0 and `thread`.`moderated` = 0 @@ -282,7 +284,7 @@ function profile_content(&$a, $update = 0) { $r = q("SELECT `thread`.`iid` AS `item_id`, `thread`.`network` AS `item_network`, `thread`.`uid` AS `contact-uid` FROM `thread` INNER JOIN `item` ON `item`.`id` = `thread`.`iid` - INNER JOIN `contact` ON `contact`.`id` = `thread`.`contact-id` + $sql_post_table INNER JOIN `contact` ON `contact`.`id` = `thread`.`contact-id` AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 WHERE `thread`.`uid` = %d AND `thread`.`visible` = 1 AND `thread`.`deleted` = 0 and `thread`.`moderated` = 0 @@ -310,7 +312,7 @@ function profile_content(&$a, $update = 0) { FROM `item`, `contact` WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 - AND `contact`.`id` = `item`.`contact-id` AND `contact`.`uid` = `item`.`uid` + AND `contact`.`id` = `item`.`contact-id` AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `item`.`parent` IN ( %s ) $sql_extra ", diff --git a/mod/search.php b/mod/search.php index 75c52fc5a0..032dc17e10 100644 --- a/mod/search.php +++ b/mod/search.php @@ -128,17 +128,6 @@ function search_content(&$a) { $tag = true; 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 group by `item`.`uri` ", - // dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG)); - //$sql_table = "`term` INNER JOIN `item` ON `item`.`id` = `term`.`oid` AND `item`.`uid` = `term`.`uid` "; - //$sql_order = "`term`.`tid`"; - //$sql_order = "`item`.`received`"; - - //$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`) "; - $sql_extra = ""; $sql_table = sprintf("`item` INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ", @@ -158,7 +147,7 @@ function search_content(&$a) { // Here is the way permissions work in the search module... // Only public posts can be shown // OR your own posts if you are a logged in member - // No items will be shown if the member has a blocked profile wall. + // No items will be shown if the member has a blocked profile wall. if( (! get_config('alt_pager', 'global')) && (! get_pconfig(local_user(),'system','alt_pager')) ) { $r = q("SELECT distinct(`item`.`uri`) as `total` diff --git a/object/Item.php b/object/Item.php index 17a723acba..3ea970e7ff 100644 --- a/object/Item.php +++ b/object/Item.php @@ -32,7 +32,7 @@ class Item extends BaseObject { public function __construct($data) { $a = $this->get_app(); - + $this->data = $data; $this->set_template('wall'); $this->toplevel = ($this->get_id() == $this->get_data_value('parent')); diff --git a/update.php b/update.php index a9cca27d91..4f3f4daec6 100644 --- a/update.php +++ b/update.php @@ -1562,7 +1562,7 @@ function update_1169() { $r = q("CREATE TABLE IF NOT EXISTS `thread` ( `iid` int(10) unsigned NOT NULL DEFAULT '0', `uid` int(10) unsigned NOT NULL DEFAULT '0', - `contact-id` int(10) unsigned NOT NULL DEFAULT '0', + `contact-id` int(11) unsigned NOT NULL DEFAULT '0', `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `edited` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `commented` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', @@ -1583,17 +1583,15 @@ function update_1169() { `mention` tinyint(1) NOT NULL DEFAULT '0', `network` char(32) NOT NULL, PRIMARY KEY (`iid`), - KEY `uid` (`uid`), - KEY `contact-id` (`contact-id`), KEY `created` (`created`), - KEY `edited` (`edited`), KEY `commented` (`commented`), - KEY `received` (`received`), - KEY `changed` (`changed`), - KEY `network` (`network`) - KEY `visible_deleted_moderated_private_wall_received` (`visible`,`deleted`,`moderated`,`private`,`wall`,`received`), - KEY `uid_visible_deleted_moderated_created` (`uid`,`visible`,`deleted`,`moderated`,`created`), - KEY `uid_visible_deleted_moderated_commented` (`uid`,`visible`,`deleted`,`moderated`,`commented`) + KEY `uid_network_commented` (`uid`,`network`,`commented`), + KEY `uid_network_created` (`uid`,`network`,`created`), + KEY `uid_contactid_commented` (`uid`,`contact-id`,`commented`), + KEY `uid_contactid_created` (`uid`,`contact-id`,`created`), + KEY `wall_private_received` (`wall`,`private`,`received`), + KEY `uid_created` (`uid`,`created`), + KEY `uid_commented` (`uid`,`commented`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8;"); if (!$r) return UPDATE_FAILED;