From c7abb1d82bbd1a3548a03d1ccf526e83132a9b1e Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 19 Dec 2018 06:39:36 -0500 Subject: [PATCH 1/2] Remove unused template variable $tabcontent in mail_head.tpl --- view/templates/mail_head.tpl | 2 -- view/theme/frio/templates/mail_head.tpl | 1 - 2 files changed, 3 deletions(-) diff --git a/view/templates/mail_head.tpl b/view/templates/mail_head.tpl index 289b93648f..d54bfc5bfb 100644 --- a/view/templates/mail_head.tpl +++ b/view/templates/mail_head.tpl @@ -1,4 +1,2 @@

{{$messages}}

- -{{$tab_content}} diff --git a/view/theme/frio/templates/mail_head.tpl b/view/theme/frio/templates/mail_head.tpl index fa4f46cf8c..70182b5e7c 100644 --- a/view/theme/frio/templates/mail_head.tpl +++ b/view/theme/frio/templates/mail_head.tpl @@ -16,4 +16,3 @@
-{{$tab_content}} From 66bf39216b890a0b89f9bef537204a5e637ac8b1 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 19 Dec 2018 06:41:08 -0500 Subject: [PATCH 2/2] Remove unreliable ANY_VALUE from message list query --- mod/message.php | 66 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 49 insertions(+), 17 deletions(-) diff --git a/mod/message.php b/mod/message.php index e0d9f4404f..af19487990 100644 --- a/mod/message.php +++ b/mod/message.php @@ -431,24 +431,56 @@ function message_content(App $a) } } -function get_messages($user, $lstart, $lend) +/** + * @param int $uid + * @param int $start + * @param int $limit + * @return array + */ +function get_messages($uid, $start, $limit) { - //TODO: rewritte with a sub-query to get the first message of each private thread with certainty - return q("SELECT max(`mail`.`created`) AS `mailcreated`, min(`mail`.`seen`) AS `mailseen`, - ANY_VALUE(`mail`.`id`) AS `id`, ANY_VALUE(`mail`.`uid`) AS `uid`, ANY_VALUE(`mail`.`guid`) AS `guid`, - ANY_VALUE(`mail`.`from-name`) AS `from-name`, ANY_VALUE(`mail`.`from-photo`) AS `from-photo`, - ANY_VALUE(`mail`.`from-url`) AS `from-url`, ANY_VALUE(`mail`.`contact-id`) AS `contact-id`, - ANY_VALUE(`mail`.`convid`) AS `convid`, ANY_VALUE(`mail`.`title`) AS `title`, ANY_VALUE(`mail`.`body`) AS `body`, - ANY_VALUE(`mail`.`seen`) AS `seen`, ANY_VALUE(`mail`.`reply`) AS `reply`, ANY_VALUE(`mail`.`replied`) AS `replied`, - ANY_VALUE(`mail`.`unknown`) AS `unknown`, ANY_VALUE(`mail`.`uri`) AS `uri`, - `mail`.`parent-uri`, - ANY_VALUE(`mail`.`created`) AS `created`, ANY_VALUE(`contact`.`name`) AS `name`, ANY_VALUE(`contact`.`url`) AS `url`, - ANY_VALUE(`contact`.`thumb`) AS `thumb`, ANY_VALUE(`contact`.`network`) AS `network`, - count( * ) as `count` - FROM `mail` LEFT JOIN `contact` ON `mail`.`contact-id` = `contact`.`id` - WHERE `mail`.`uid` = %d GROUP BY `parent-uri` ORDER BY `mailcreated` DESC LIMIT %d , %d ", - intval($user), intval($lstart), intval($lend) - ); + return DBA::toArray(DBA::p('SELECT + m.`id`, + m.`uid`, + m.`guid`, + m.`from-name`, + m.`from-photo`, + m.`from-url`, + m.`contact-id`, + m.`convid`, + m.`title`, + m.`body`, + m.`seen`, + m.`reply`, + m.`replied`, + m.`unknown`, + m.`uri`, + m.`parent-uri`, + m.`created`, + c.`name`, + c.`url`, + c.`thumb`, + c.`network`, + m2.`count`, + m2.`mailcreated`, + m2.`mailseen` + FROM `mail` m + JOIN ( + SELECT + `parent-uri`, + MIN(`id`) AS `id`, + COUNT(*) AS `count`, + MAX(`created`) AS `mailcreated`, + MIN(`seen`) AS `mailseen` + FROM `mail` + WHERE `uid` = ? + GROUP BY `parent-uri` + ) m2 ON m.`parent-uri` = m2.`parent-uri` AND m.`id` = m2.`id` + LEFT JOIN `contact` c ON m.`contact-id` = c.`id` + WHERE m.`uid` = ? + ORDER BY m2.`mailcreated` DESC + LIMIT ?, ?' + , $uid, $uid, $start, $limit)); } function render_messages(array $msg, $t)