https://www.icyphoenix.com/viewtopic.php?f=35&t=8651&p=56468#p56468
-----------------------------------
jhl
Sat 25 Aug, 2012 13:19

Re: The 'New' Link And Display Page
-----------------------------------
[quote user="Joshua203" post="56440"]It took me a while  :roll: but I guess this is it..
http://www.icyphoenix.com/viewtopic.php?f=10&t=8136&start=0[/quote]

Yes, I think you're right. There seems to be a bit of confusion though. Meanwhile I took a look at the code, which has a few discrepancies...
First of all, let's see if I can clear things up a little (or possibly confuse everyone more).

[size=14][b]Overview[/b][/size]
There are two systems for new/unread/et al messages - cookie based and DB based (UPI2DB). I haven't looked at UPI2DB at all, so I won't mention it further here.

The number of new posts appears only in specified pages (all forums and single forum usually) to reduce DB hits, but [i]always[/i] displays the number of new posts since you last logged in (irrespective of using cookies or UPI2DB).
So if you want to reduce the list you [b]must[/b] log out, then log in again. Here 'New' refers to posts published after you logged in, even if you've read one or more of the posts.

That's just how it is, and that's what I'll explain to my users. New != Unread.

[size=14][b]Discrepancies[/b][/size]
Now to the discrepancies. I'm making reference to the PHP code, mostly.
The 'New' count in the link is calculated using an SQL query (includes/functions.php, line 4539):
[code linenumbers=false]$sql = "SELECT COUNT(post_id) as total FROM " . POSTS_TABLE . " WHERE post_time >= " . $user->data['user_lastvisit'] . AND poster_id != " . $user->data['user_id'];[/code]
which basically says "get the post counts since you last logged in, that aren't yours".

However, in the actual search page, the SQL query is (search.php, line 329):
[code linenumbers=false]$sql = "SELECT post_id FROM " . POSTS_TABLE . " WHERE post_time >= " . $user->data['user_lastvisit'];[/code]
this says "get every post since you last logged in".
This will (or should) produce more results, because it [i]will[/i] also include your own posts, whereas the counter didn't.

But, then the results page uses the topic format to display the results. This will mean that although there could have been say 20 new posts, if they were all in a single topic, you'll only see one line of results.

[size=14][b]Possible alternatives[/b][/size]
The first discrepancy is very minor - either add the 'your posts' filter to the search query, or remove it from the count query. I don't see this being a problem. Personally, I'd remove the filter from the count query.

The second discrepancy seems more 'conceptual' than mathematical. If New refers to posts, why show the results using the topics format? Wouldn't it be more reasonable to show the results using the posts format?
Or, if the results are shown as topics (which displays less information, when there are many new posts), shouldn't the count refer to the number of [b]topics[/b] with new posts?

(For those who might not know these two formats, you can choose one or the other in the search panel, see below, where the cursor is)
[align=center] [img]http://www.icyphoenix.com/files/images/10300/search.jpg[/img] [/align]

Thoughts?

John


