Design issue Stop watching threads: If last page is emptied, page no. remains in navigation

CTXMedia

Well-known member
To test:
  • Go to your watched threads.
  • Click - Show all watched threads.
  • Navigate to the last page.
  • Tick all entries on that last page and select Stop watching.
  • Navigate to another page (you'll see the page number for the last page remains active).
  • Navigate back to the last page (displays empty page).
The enumeration of the navigation bar does get recalculated if you remove another page of entries - so it's as if there is a spurious (but invisible) entry that it keeping that last page "active" for the navigation; or the count is somehow +1 'ing and causing an extra page to be added to the count.

Cheers,
Shaun :D
 
Yuck. I bet this is incorrect on purpose.

You have to do permission checks on each thread to get an accurate count, and they are all from different forums. The permission check can't be done in SQL because of how permissions are stored.

It's not a small change so I will leave it to the devs. The way I would do it is to fetch all watched thread_ids and their permission values (only those two fields) for the user in question, leaving you with data like this:

Code:
array(
	0 => array('thread_id' => 1, 'node_permission_cache' => BLOB),
	1 => array('thread_id' => 2, 'node_permission_cache' => BLOB),
	2 => array('thread_id' => 3, 'node_permission_cache' => BLOB),
	3 => array('thread_id' => 4, 'node_permission_cache' => BLOB),
	4 => array('thread_id' => 5, 'node_permission_cache' => BLOB),
	5 => array('thread_id' => 6, 'node_permission_cache' => BLOB),
	6 => array('thread_id' => 7, 'node_permission_cache' => BLOB),
)

Then parry them down with permission checks in PHP. Let's say you lose 2 threads to permissions:

Code:
array(
	0 => array('thread_id' => 1, 'node_permission_cache' => BLOB),
	1 => array('thread_id' => 2, 'node_permission_cache' => BLOB),
	3 => array('thread_id' => 4, 'node_permission_cache' => BLOB),
	4 => array('thread_id' => 5, 'node_permission_cache' => BLOB),
	6 => array('thread_id' => 7, 'node_permission_cache' => BLOB),
)

Now the number of records you have left is the total for the pagination. Just count() the array.

Then foreach the array and gather the thread_ids you need for the current page. Fetch those thread records (WHERE thread_id IN...).

This is the most efficient way in my mind. This should have acceptable overhead.
 
In general, this is a design issue. While we could try to do these permission checks, you could theoretically have tens of thousands of watched threads, and these permission checks wouldn't necessarily scale. Maybe in the future we could do some level of limiting though.
 
Top Bottom