Mark [Topic] Unread - Can't figure out what's the intended behavior

Started by jnghh, June 13, 2007, 11:27:13 PM

Previous topic - Next topic

jnghh

Here's what I'm seeing on my board, simplified:
- I have a thread mark as new that's perhaps five pages long.
- Clicking on the "new" icon takes me to my last read page/post, let's say in this case, that's page three.
- I have only time to read that page, so I decide I'll read page four and five later.
-However, when I go back to my main page, I see that the entire thread no longer has any "new" posts.
- Okay, I think to myself, that makes sense. Although I've not read it yet, I went into the thread and it's really no longer "new".
- I decide to try and work around the situation by using the "mark unread" feature.
- I go into the thread on page three and click "mark unread"
- I check my index and see that the "new" button is back, but when I test it out, it takes me to the end of page five (or the end of the thread), when I was expecting to go to page three (or four).

I tried digging into the code to get a clearer picture and came on this :

Code (Sub-Boards.php) Select

// Special case: mark a topic unread!
elseif (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'topic')
{
if (!empty($_GET['t']))
{
// Get the latest message before this one.
$result = db_query("
SELECT MAX(ID_MSG)
FROM {$db_prefix}messages
WHERE ID_TOPIC = $topic
AND ID_MSG < " . (int) $_GET['t'], __FILE__, __LINE__);
list ($earlyMsg) = mysql_fetch_row($result);
mysql_free_result($result);
}

if (empty($earlyMsg))
{
$result = db_query("
SELECT ID_MSG
FROM {$db_prefix}messages
WHERE ID_TOPIC = $topic
ORDER BY ID_MSG
LIMIT " . (int) $_REQUEST['start'] . ", 1", __FILE__, __LINE__);
list ($earlyMsg) = mysql_fetch_row($result);
mysql_free_result($result);
}

$earlyMsg--;

// Use a time one second earlier than the first time: blam, unread!
db_query("
REPLACE INTO {$db_prefix}log_topics
(ID_MSG, ID_MEMBER, ID_TOPIC)
VALUES ($earlyMsg, $ID_MEMBER, $topic)", __FILE__, __LINE__);


It seems that it tries to get the ID of the message that should be considered as my last read message. And it uses the ['t'] query string. I couldn't find where the t value was pulled, but I studied the links on my pages; most of the time it's some extremely high number, and it's not the ID of any message in the thread nor is it a number that's close to the last message ID in the thread.

Shouldn't it be the ID of the first message on the page that's being displayed, though?

For instance, if I'm on page 3, and the first message ID is 3566, shouldn't the the Mark Unread topic's link pass t=3566 so that the code will query for the maximum ID that falls earlier than 3566 ?

I'm confused. Have I gotten the intended behavior wrong?

SleePy

Does T look like 3566? format or is it different? Examples?
I think it should either be a message ID number, topic ID number or the unix timestamp
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

jnghh

Hmm, I can't recall if the 3566  was an actual example, but what I'm getting now are 5-digit numbers. Some real examples:

action=markasread;sa=topic;t=65891;topic=116.0;
action=markasread;sa=topic;t=66013;topic=911.0;
action=markasread;sa=topic;t=69074;topic=116.0;
action=markasread;sa=topic;t=69074;topic=116.30
action=markasread;sa=topic;t=64783;topic=132.120;

[For topic=166.0 -- it shows that the t value is still the same, no matter what page I'm at.]

Timestamp--I hadn't thought of that! Are these timestamp formats? And if it is, the statement

SELECT MAX(ID_MSG)
FROM {$db_prefix}messages
WHERE ID_TOPIC = $topic
AND ID_MSG < " . (int) $_GET['t']


wouldn't be quite right, would it?

SleePy

Well looking at those examples I am sure it is not a timestamp.

T is actually the Message ID. It should be the last message ID you read in that topic. Which is why it is trying to get the number of messages I guess that are new.

Reading your topic again this makes sense.
Since you read the topic by viewing it you have in a sense viewed the topic. SMF doesn't do detection to figure out what the last post you read was.
So when you clicked new you went into the topic and from what SMF knows read the topic.

The same thing is done for boards. If you view the board you have in a sense read the board.
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

jnghh

Quote from: SleePy on June 26, 2007, 12:34:59 AM
It should be the last message ID you read in that topic.

That's what I would expect, too, but the value of T is some very high number that does not represent any of the posts in the thread I'm in. Which leads me to wonder if this is a bug or if I'm misunderstood the intended behavior. Thought I'd ask the experts first ;)

Quote
SMF doesn't do detection to figure out what the last post you read was.

Hmm.. I thought it does? Isn't that how the "new" feature works? It puts me to the place where I last read?

SleePy

Check what the last message ids where. If you click the subject for the last message you should see in your address bar a .msg####
That is the messages ID. It should be really close to the messages you are reading.
SMF can't really detect where you are. How does it know if you read 2 or 3 of those messages and not the rest? How would it know if you read the whole thing or not?
The new either takes you to the last post that was read or to the end. So when you mark unread it removes the entry that you have read it but since you clicked new it takes you to the end (As it assumes you want the newest posts).
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

Advertisement: