Download & Extend

Mailbox pager count query optimization fails

Project:Privatemsg Views
Version:6.x-1.x-dev
Component:Code
Category:task
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

Pager doesnt work.

This code do for your default views

<?php
function mymodule_views_pre_execute(&$view) {
   
    if (
$view->name == 'privatemsg_mailbox'   ) {
       
$view->build_info['count_query'] = 'SELECT (pm_message.mid)  FROM {pm_message} pm_message INNER JOIN {pm_index} pm_index ON pm_message.mid = pm_index.mid WHERE (pm_index.deleted = 0) AND (pm_index.uid = %d)';
    }
}
?>

Comments

#1

Priority:normal» major

Thanks for the tip, but the query you're suggesting is wrong. There's no GROUP BY or DISTINCT in it thus it doesn't represent base query. You are simply counting messages, we OTOH need to count threads.
But I would like to avoid the approach, cause it works in a limited way and is closely tied to the supplied view. Would be best to work out a solution that worked for all views.

#2

Title:Pager do not work» Mailbox pager does not work

#3

For anyone interested, I described the problem in the Views queue: #904284: Count query optimization code only checks $this->groupby and not presence of "aggregate" fields.

#4

Status:active» needs review

Attaching temporary fix until the aforementioned request is answered

AttachmentSize
privatemsg_views_861560.patch 989 bytes

#5

Better patch from the root of the module.

AttachmentSize
privatemsg_views_861560.patch 1.04 KB

#6

I've committed the patch above to the dev branch. Not closing this issue to wait for proper solution.

#7

Title:Mailbox pager does not work» Mailbox pager count query optimization fails
Category:bug report» task
Status:needs review» active

Ok, since this is fixed in dev, changing to a task.

#8

Priority:major» normal
nobody click here