From d5ae5ecedd526e3a35084257e6a9101340cdf9b1 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 15 Sep 2013 10:40:58 +0200 Subject: [PATCH 1/7] - Improved speed due to forced indexes when showing items. - Possibility to setup a hostname --- boot.php | 36 ++++++++++++++++++++++-------------- include/conversation.php | 9 ++++----- include/dba.php | 4 +++- index.php | 9 +++------ mod/display.php | 6 +++--- mod/network.php | 9 +-------- mod/profile.php | 2 +- object/Conversation.php | 4 ++++ 8 files changed, 41 insertions(+), 38 deletions(-) diff --git a/boot.php b/boot.php index 99eb3d0c17..693b70ba84 100644 --- a/boot.php +++ b/boot.php @@ -289,7 +289,7 @@ define ( 'GRAVITY_COMMENT', 6); */ function startup() { - + error_reporting(E_ERROR | E_WARNING | E_PARSE); set_time_limit(0); @@ -389,7 +389,7 @@ if(! class_exists('App')) { 'stylesheet' => '', 'template_engine' => 'smarty3', ); - + // array of registered template engines ('name'=>'class name') public $template_engines = array(); // array of instanced template engines ('name'=>'instance') @@ -420,6 +420,9 @@ if(! class_exists('App')) { global $default_timezone, $argv, $argc; + if (file_exists(".htpreconfig.php")) + @include(".htpreconfig.php"); + $this->timezone = ((x($default_timezone)) ? $default_timezone : 'UTC'); date_default_timezone_set($this->timezone); @@ -453,7 +456,7 @@ if(! class_exists('App')) { if(x($_SERVER,'HTTPS') && $_SERVER['HTTPS']) $this->scheme = 'https'; elseif(x($_SERVER,'SERVER_PORT') && (intval($_SERVER['SERVER_PORT']) == 443)) - $this->scheme = 'https'; + $this->scheme = 'https'; if(x($_SERVER,'SERVER_NAME')) { $this->hostname = $_SERVER['SERVER_NAME']; @@ -478,13 +481,17 @@ if(! class_exists('App')) { if(isset($path) && strlen($path) && ($path != $this->path)) $this->path = $path; } + + if ($hostname != "") + $this->hostname = $hostname; + if (is_array($argv) && $argc>1 && substr(end($argv), 0, 4)=="http" ) { $this->set_baseurl(array_pop($argv) ); $argc --; } set_include_path("include/$this->hostname" . PATH_SEPARATOR . get_include_path()); - + if((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,2) === "q=") { $this->query_string = substr($_SERVER['QUERY_STRING'],2); // removing trailing / - maybe a nginx problem @@ -550,7 +557,7 @@ if(! class_exists('App')) { $mobile_detect = new Mobile_Detect(); $this->is_mobile = $mobile_detect->isMobile(); $this->is_tablet = $mobile_detect->isTablet(); - + /** * register template engines */ @@ -560,7 +567,7 @@ if(! class_exists('App')) { $this->register_template_engine($k); } } - + } function get_basepath() { @@ -640,7 +647,7 @@ if(! class_exists('App')) { $this->pager['itemspage'] = ((intval($n) > 0) ? intval($n) : 0); $this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage']; } - + function set_pager_page($n) { $this->pager['page'] = $n; $this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage']; @@ -773,7 +780,7 @@ if(! class_exists('App')) { $template_engine = $this->theme['template_engine']; } } - + if (isset($this->template_engines[$template_engine])){ if(isset($this->template_engine_instance[$template_engine])){ return $this->template_engine_instance[$template_engine]; @@ -784,7 +791,7 @@ if(! class_exists('App')) { return $obj; } } - + echo "template engine $template_engine is not registered!\n"; killme(); } @@ -827,6 +834,7 @@ if(! class_exists('App')) { //$this->performance["markstart"] -= microtime(true) - $this->performance["marktime"]; $this->performance["markstart"] = microtime(true) - $this->performance["markstart"] - $this->performance["marktime"]; } + } } @@ -1008,7 +1016,7 @@ if(! function_exists('update_db')) { )); $subject=sprintf(t('Update Error at %s'), $a->get_baseurl()); require_once('include/email.php'); - $subject = email_header_encode($subject,'UTF-8'); + $subject = email_header_encode($subject,'UTF-8'); mail($a->config['admin_email'], $subject, $email_msg, 'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME'] . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" @@ -1020,7 +1028,7 @@ if(! function_exists('update_db')) { else { set_config('database','update_' . $x, 'success'); set_config('system','build', $x + 1); - } + } } } } @@ -1288,7 +1296,7 @@ if(! function_exists('profile_load')) { $user = q("select uid from user where nickname = '%s' limit 1", dbesc($nickname) ); - + if(! ($user && count($user))) { logger('profile error: ' . $a->query_string, LOGGER_DEBUG); notice( t('Requested account is not available.') . EOL ); @@ -1310,7 +1318,7 @@ if(! function_exists('profile_load')) { } $r = null; - + if($profile) { $profile_int = intval($profile); $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `user`.* FROM `profile` @@ -1334,7 +1342,7 @@ if(! function_exists('profile_load')) { $a->error = 404; return; } - + // fetch user tags if this isn't the default profile if(! $r[0]['is-default']) { diff --git a/include/conversation.php b/include/conversation.php index 2e336efab0..31f40aa6f8 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -487,7 +487,6 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { $alike = array(); $dlike = array(); - // array with html for each thread (parent+comments) $threads = array(); $threadsid = -1; @@ -516,7 +515,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { if($blocked) continue; } - + $threadsid++; @@ -697,7 +696,6 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { $threads[$threadsid]['items'] = array($arr['output']); } - } else { @@ -719,7 +717,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { if($arr_blocked) { $blocked = false; foreach($arr_blocked as $b) { - + if($b && link_compare($item['author-link'],$b)) { $blocked = true; break; @@ -728,7 +726,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { if($blocked) continue; } - + // Can we put this after the visibility check? @@ -754,6 +752,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { } $threads = $conv->get_template_data($alike, $dlike); + if(!$threads) { logger('[ERROR] conversation : Failed to get template data.', LOGGER_DEBUG); $threads = array(); diff --git a/include/dba.php b/include/dba.php index 50354b7f49..dae1455931 100644 --- a/include/dba.php +++ b/include/dba.php @@ -93,6 +93,8 @@ class dba { $stamp2 = microtime(true); $duration = (float)($stamp2-$stamp1); + $a->save_timestamp($stamp1, "database"); + if(x($a->config,'system') && x($a->config['system'],'db_log')) { if (($duration > $a->config["system"]["db_loglimit"])) { $duration = round($duration, 3); @@ -168,7 +170,7 @@ class dba { } } - $a->save_timestamp($stamp1, "database"); + //$a->save_timestamp($stamp1, "database"); if($this->debug) logger('dba: ' . printable(print_r($r, true))); diff --git a/index.php b/index.php index 6b6e873ea6..8784b5d0eb 100644 --- a/index.php +++ b/index.php @@ -104,12 +104,12 @@ if((x($_GET,'zrl')) && (!$install && !$maintenance)) { * For Mozilla auth manager - still needs sorting, and this might conflict with LRDD header. * Apache/PHP lumps the Link: headers into one - and other services might not be able to parse it * this way. There's a PHP flag to link the headers because by default this will over-write any other - * link header. + * link header. * * What we really need to do is output the raw headers ourselves so we can keep them separate. * */ - + // header('Link: <' . $a->get_baseurl() . '/amcd>; rel="acct-mgmt";'); if((x($_SESSION,'authenticated')) || (x($_POST,'auth-params')) || ($a->module === 'login')) @@ -136,7 +136,6 @@ if(! x($_SESSION,'sysmsg_info')) * any plugins have been added or removed and reacts accordingly. */ - if($install) $a->module = 'install'; elseif($maintenance) @@ -191,7 +190,7 @@ if(strlen($a->module)) { // Compatibility with the Android Diaspora client if ($a->module == "stream") $a->module = "network"; - + $privateapps = get_config('config','private_addons'); if(is_array($a->plugins) && in_array($a->module,$a->plugins) && file_exists("addon/{$a->module}/{$a->module}.php")) { @@ -320,10 +319,8 @@ if($a->module_loaded) { $func = str_replace('-','_',current_theme()) . '_content_loaded'; $func($a); } - } - /* * Create the page head after setting the language * and getting any auth credentials diff --git a/mod/display.php b/mod/display.php index 24ce35791a..538dc6454f 100644 --- a/mod/display.php +++ b/mod/display.php @@ -123,7 +123,7 @@ function display_content(&$a, $update = 0) { if($update) { $r = q("SELECT id FROM item WHERE item.uid = %d - AND `item`.`parent` = ( SELECT `parent` FROM `item` WHERE ( `id` = '%s' OR `uri` = '%s' )) + AND `item`.`parent` = ( SELECT `parent` FROM `item` FORCE INDEX (PRIMARY, `uri`) WHERE ( `id` = '%s' OR `uri` = '%s' )) $sql_extra AND unseen = 1", intval($a->profile['uid']), dbesc($item_id), @@ -142,7 +142,7 @@ function display_content(&$a, $update = 0) { WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 - AND `item`.`parent` = ( SELECT `parent` FROM `item` WHERE ( `id` = '%s' OR `uri` = '%s' ) + AND `item`.`parent` = ( SELECT `parent` FROM `item` FORCE INDEX (PRIMARY, `uri`) WHERE ( `id` = '%s' OR `uri` = '%s' ) AND uid = %d ) $sql_extra ORDER BY `parent` DESC, `gravity` ASC, `id` ASC ", @@ -171,7 +171,7 @@ function display_content(&$a, $update = 0) { WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 - AND `item`.`parent` = ( SELECT `parent` FROM `item` WHERE `uri` = '%s' AND uid = %d ) + AND `item`.`parent` = ( SELECT `parent` FROM `item` FORCE INDEX (PRIMARY, `uri`) WHERE `uri` = '%s' AND uid = %d ) ORDER BY `parent` DESC, `gravity` ASC, `id` ASC ", intval(local_user()), dbesc($item_uri), diff --git a/mod/network.php b/mod/network.php index 624169511a..7195092ea1 100644 --- a/mod/network.php +++ b/mod/network.php @@ -376,7 +376,6 @@ function network_content(&$a, $update = 0) { } } - $o = ''; // item filter tabs @@ -498,10 +497,6 @@ function network_content(&$a, $update = 0) { // --- end item filter tabs - - - - $contact_id = $a->cid; require_once('include/acl_selectors.php'); @@ -572,7 +567,6 @@ function network_content(&$a, $update = 0) { } - // We don't have to deal with ACLs on this page. You're looking at everything // that belongs to you, hence you can see all of it. We will filter by group if // desired. @@ -849,7 +843,6 @@ function network_content(&$a, $update = 0) { $update_unseen = ' WHERE uid = ' . intval(local_user()) . ' AND unseen = 1 AND parent IN ( ' . dbesc($parents_str) . ' )'; } - // We aren't going to try and figure out at the item, group, and page // level which items you've seen and which you haven't. If you're looking // at the top level network page just mark everything seen. @@ -864,7 +857,7 @@ function network_content(&$a, $update = 0) { // on they just get buried deeper. It has happened to me a couple of times also. if((! $group) && (! $cid) && (! $star)) { - $r = q("UPDATE `item` SET `unseen` = 0 + $r = q("UPDATE `item` SET `unseen` = 0 WHERE `unseen` = 1 AND `uid` = %d", intval(local_user()) ); diff --git a/mod/profile.php b/mod/profile.php index a7b576488e..c5f787a4f0 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -277,7 +277,7 @@ function profile_content(&$a, $update = 0) { $pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage'])); $r = q("SELECT `item`.`id` AS `item_id`, `contact`.`uid` AS `contact-uid` - FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` + FROM `item` FORCE INDEX (created) LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `item`.`id` = `item`.`parent` AND `item`.`wall` = 1 diff --git a/object/Conversation.php b/object/Conversation.php index bd7a95cf2a..fd1e282cab 100644 --- a/object/Conversation.php +++ b/object/Conversation.php @@ -130,10 +130,14 @@ class Conversation extends BaseObject { global $a; $result = array(); + $i = 0; + foreach($this->threads as $item) { if($item->get_data_value('network') === NETWORK_MAIL && local_user() != $item->get_data_value('uid')) continue; + $item_data = $item->get_template_data($alike, $dlike); + if(!$item_data) { logger('[ERROR] Conversation::get_template_data : Failed to get item template data ('. $item->get_id() .').', LOGGER_DEBUG); return false; From 507577065427d6a6b24e30628ce46d9152825544 Mon Sep 17 00:00:00 2001 From: Silke Meyer Date: Tue, 24 Sep 2013 00:28:35 +0200 Subject: [PATCH 2/7] Transferred link link from Neptune theme (by 23n) to frost-mobile --- view/theme/frost-mobile/images/link.png | Bin 0 -> 488 bytes view/theme/frost-mobile/style.css | 9 ++++++++- view/theme/frost-mobile/templates/jot.tpl | 12 +++++------- 3 files changed, 13 insertions(+), 8 deletions(-) create mode 100644 view/theme/frost-mobile/images/link.png diff --git a/view/theme/frost-mobile/images/link.png b/view/theme/frost-mobile/images/link.png new file mode 100644 index 0000000000000000000000000000000000000000..7c5c8ed6bb8928183855a050f038f499e7dabd9c GIT binary patch literal 488 zcmVP)J)4uv(+`W^oR8@w2SZsUaV5y~4;y2>Am% z#!BLjm8ycxCGZrd3g=E^I^?|5z?pUxi8Tx-q>CXu!jA^Vi?UrT*zV%njND$rr+peP z%5Ti{)hNbEJj1{NzMNn9nj49B2w&#_
-
+ {{**}} +
-->*}} + {{**}} + +
From 53040c08142e3d5aeecbe7785ecff7c9a91e13a9 Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 24 Sep 2013 09:18:29 +0200 Subject: [PATCH 3/7] Update style.css no opacity for remote-link icon --- view/theme/frost-mobile/style.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/theme/frost-mobile/style.css b/view/theme/frost-mobile/style.css index e76ceac77d..85f2b462e1 100644 --- a/view/theme/frost-mobile/style.css +++ b/view/theme/frost-mobile/style.css @@ -3796,7 +3796,7 @@ aside input[type='text'] { background-size: 100% 100%; background-image: url('images/link.png'); background-repeat: no-repeat; - opacity: 0.5; + } /*.globe { background-position: 0px -16px;}*/ From ab7d8bc6abe79a5384a8e2c284eca7eae1b16b60 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Fri, 27 Sep 2013 23:02:59 +0200 Subject: [PATCH 4/7] Delete all APC values before showing them in the settings and admin section --- mod/admin.php | 5 +++++ mod/settings.php | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/mod/admin.php b/mod/admin.php index 4539e4192b..f1f895dbcc 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -87,6 +87,11 @@ function admin_content(&$a) { if(x($_SESSION,'submanage') && intval($_SESSION['submanage'])) return ""; + if (function_exists("apc_delete")) { + $toDelete = new APCIterator('user', APC_ITER_VALUE); + apc_delete($toDelete); + } + /** * Side bar links */ diff --git a/mod/settings.php b/mod/settings.php index f9d5b712ca..12f7910cce 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -16,6 +16,11 @@ function get_theme_config_file($theme){ function settings_init(&$a) { + if (function_exists("apc_delete")) { + $toDelete = new APCIterator('user', APC_ITER_VALUE); + apc_delete($toDelete); + } + // These lines provide the javascript needed by the acl selector $tpl = get_markup_template("settings-head.tpl"); From d126924ae0a9c9dd2b9b96e107e44848078b6bde Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Wed, 2 Oct 2013 22:17:56 +0200 Subject: [PATCH 5/7] Vimeo videos are now embedded via SSL. --- include/bbcode.php | 7 ++++--- include/diaspora.php | 7 +++---- include/notifier.php | 8 +++----- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/include/bbcode.php b/include/bbcode.php index f07c1aa6c3..0f8c2df74e 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -38,7 +38,8 @@ function tryoembed($match){ $url = ((count($match)==2)?$match[1]:$match[2]); // Always embed the SSL version - $url = str_replace("http://www.youtube.com/", "https://www.youtube.com/", $url); + $url = str_replace(array("http://www.youtube.com/", "http://player.vimeo.com/"), + array("https://www.youtube.com/", "https://player.vimeo.com/"), $url); //logger("tryoembed: $url"); @@ -666,9 +667,9 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal $Text = preg_replace("/\[vimeo\]https?:\/\/vimeo.com\/([0-9]+)(.*?)\[\/vimeo\]/ism",'[vimeo]$1[/vimeo]',$Text); if ($tryoembed) - $Text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", '', $Text); + $Text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", '', $Text); else - $Text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", "http://vimeo.com/$1", $Text); + $Text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", "https://vimeo.com/$1", $Text); // $Text = preg_replace("/\[youtube\](.*?)\[\/youtube\]/", '', $Text); diff --git a/include/diaspora.php b/include/diaspora.php index 4f1eb22234..f4ce6cb760 100755 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -2667,16 +2667,15 @@ function diaspora_transmit($owner,$contact,$slap,$public_batch,$queue_run=false) $return_code = 0; } else { - if(! intval(get_config('system','diaspora_test'))) { + if (!intval(get_config('system','diaspora_test'))) { post_url($dest_url . '/', $slap); $return_code = $a->get_curl_code(); - } - else { + } else { logger('diaspora_transmit: test_mode'); return 200; } } - + logger('diaspora_transmit: ' . $logid . ' returns: ' . $return_code); if((! $return_code) || (($return_code == 503) && (stristr($a->get_curl_headers(),'retry-after')))) { diff --git a/include/notifier.php b/include/notifier.php index 74597c30d2..3f9c286ed7 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -663,7 +663,7 @@ function notifier_run(&$argv, &$argc){ // if contact's ssl policy changed, which we just determined // is on our own server, update our contact links - + $ssl_policy = get_config('system','ssl_policy'); fix_contact_ssl_policy($x[0],$ssl_policy); @@ -675,17 +675,15 @@ function notifier_run(&$argv, &$argc){ require_once('library/simplepie/simplepie.inc'); logger('mod-delivery: local delivery'); local_delivery($x[0],$atom); - break; + break; } } - - logger('notifier: dfrndelivery: ' . $contact['name']); $deliver_status = dfrn_deliver($owner,$contact,$atom); logger('notifier: dfrn_delivery returns ' . $deliver_status); - + if($deliver_status == (-1)) { logger('notifier: delivery failed: queuing message'); // queue message for redelivery From 8adc1bd703a6f610296691dabf54c5b8fd0e1699 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Fri, 4 Oct 2013 11:12:29 +0200 Subject: [PATCH 6/7] Vier: Improved scrollbar when the "aside" area is to short. --- view/theme/vier/style.css | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/view/theme/vier/style.css b/view/theme/vier/style.css index 658ce1b735..359907dbd9 100644 --- a/view/theme/vier/style.css +++ b/view/theme/vier/style.css @@ -863,19 +863,21 @@ aside { /* display: table-cell; */ vertical-align: top; width: 185px; - padding: 32px 10px 10px 20px; + /* padding: 32px 10px 10px 20px; */ + padding: 10px 10px 0px 20px; /* border-right: 1px solid #D2D2D2; */ /* background-color: #ECECF2; */ background-color: #F2F2F2; font-size: 13px; /* background: #F1F1F1; */ - top: 0px; + /* top: 0px; */ + top: 32px; overflow-y: auto; z-index: 2; position: fixed; /* overflow: auto; */ - height: 100%; + height: calc(100% - 42px); /* overflow: scroll; */ } aside .vcard .fn { From 2d1b261fad5b92568b1572b36b3618d149323fa0 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sat, 5 Oct 2013 12:30:10 +0200 Subject: [PATCH 7/7] Speed improvements of queries --- include/api.php | 25 +++++++++++++++++++------ mod/community.php | 2 +- mod/profile.php | 2 +- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/include/api.php b/include/api.php index 5e80e0f0a3..cfbf7a7e5c 100644 --- a/include/api.php +++ b/include/api.php @@ -619,19 +619,32 @@ function api_status_show(&$a, $type){ $user_info = api_get_user($a); // get last public wall message - $lastwall = q("SELECT `item`.*, `i`.`contact-id` as `reply_uid`, `i`.`nick` as `reply_author` - FROM `item`, `contact`, - (SELECT `item`.`id`, `item`.`contact-id`, `contact`.`nick` FROM `item`,`contact` WHERE `contact`.`id`=`item`.`contact-id`) as `i` + + $lastwall = q("SELECT `item`.*, `i`.`contact-id` as `reply_uid`, `c`.`nick` as `reply_author` + FROM `item`, `contact`, `item` as `i`, `contact` as `c` WHERE `item`.`contact-id` = %d AND `i`.`id` = `item`.`parent` - AND `contact`.`id`=`item`.`contact-id` AND `contact`.`self`=1 - AND `type`!='activity' + AND `contact`.`id`=`item`.`contact-id` AND `c`.`id`=`i`.`contact-id` AND `contact`.`self`=1 + AND `item`.`type`!='activity' AND `item`.`allow_cid`='' AND `item`.`allow_gid`='' AND `item`.`deny_cid`='' AND `item`.`deny_gid`='' - ORDER BY `created` DESC + ORDER BY `item`.`created` DESC LIMIT 1", intval($user_info['id']) ); +// $lastwall = q("SELECT `item`.*, `i`.`contact-id` as `reply_uid`, `i`.`nick` as `reply_author` +// FROM `item`, `contact`, +// (SELECT `item`.`id`, `item`.`contact-id`, `contact`.`nick` FROM `item`,`contact` WHERE `contact`.`id`=`item`.`contact-id`) as `i` +// WHERE `item`.`contact-id` = %d +// AND `i`.`id` = `item`.`parent` +// AND `contact`.`id`=`item`.`contact-id` AND `contact`.`self`=1 +// AND `type`!='activity' +// AND `item`.`allow_cid`='' AND `item`.`allow_gid`='' AND `item`.`deny_cid`='' AND `item`.`deny_gid`='' +// ORDER BY `created` DESC +// LIMIT 1", +// intval($user_info['id']) +// ); + if (count($lastwall)>0){ $lastwall = $lastwall[0]; diff --git a/mod/community.php b/mod/community.php index 1f8adf8907..dbf4c82beb 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` FORCE INDEX (`received`) LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` + FROM `item` FORCE INDEX (`received`, `wall`) 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/profile.php b/mod/profile.php index c5f787a4f0..c5da0ebed3 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -277,7 +277,7 @@ function profile_content(&$a, $update = 0) { $pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage'])); $r = q("SELECT `item`.`id` AS `item_id`, `contact`.`uid` AS `contact-uid` - FROM `item` FORCE INDEX (created) LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` + FROM `item` FORCE INDEX (created, uid) LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `item`.`id` = `item`.`parent` AND `item`.`wall` = 1