Merlin Sythove wrote: Another refresh *would* show it as unread
No-no, i just did some 20 refreshes during the post submission & finally achieved wholly read post, as it was before the fix. I'll try moving the block to some place in posting.php...
FaKeOnE-rSe wrote: ...I also have installed simple subforums mod mod which doesn't works with the keep unread flags...
asinshesq wrote:FaKeOnE-rSe wrote:...I also have installed simple subforums mod mod which doesn't works with the keep unread flags...
I don't have access to my files here but isn't there an author's note in the mod about this?
Code: Select all
## Similarly, if you want to run this with simple subforums, you need to make some additional modifications figured out by Wicher; go to
## this post for a solution: http://www.phpbb.com/phpBB/viewtopic.php?p=2033623#2033623 (you may also want to check
## here in case there is a new version of that mod: http://www.phpbb.com/phpBB/viewtopic.php?p=2090189#2090189 or directly at:
## http://www.detecties.com/phpbb2018/viewtopic.php?t=15 )
Code: Select all
$board_config['tracking_time'] = time();
Code: Select all
//MOD Keep_unread: solving refresh bypassing new posts
$sql = "SELECT MAX(post_time) AS maxtime
FROM " . POSTS_TABLE;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not query latest post information', '', __LINE__, __FILE__, $sql);
}
$row = $db->sql_fetchrow($result);
$board_config['tracking_time'] = $row['maxtime'];
Code: Select all
$board_config['tracking_unreads'][$topic_id]
Code: Select all
$sql = "SELECT post_id, post_time
FROM " . POSTS_TABLE . "
WHERE post_time > " . $board_config['tracking_unreads'][$topic_id] . "
AND topic_id = $topic_id
ORDER BY post_time
LIMIT 1";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not query latest post information', '', __LINE__, __FILE__, $sql);
}
$row = $db->sql_fetchrow($result);
if ($row['post_id'] == $post_id)
{
$board_config['tracking_unreads'][$topic_id] = $row['post_time'];
}
asinshesq wrote: Clever.
But merlin, I was thinking some more about the original problem and suddenly realized that perhaps the fix (artificially updating the timestamp for a post when the post is complete) does more harm than good.
A while back, I discovered that if the post with the largest post_id in a topic (last_post_id) has a timestamp that is not as great as a post with a lower post_id, that triggers the sync() function whenever any user happens to be looking at the last page of that topic.
Merlin Sythove wrote: Hmm, I can't find sync being called in any unusual way in viewtopic. Please explain.
asinshesq wrote: Viewtopic executes a sync when the last_post_id is no longer the last post by timestamp.
Code: Select all
if ($postrow[$row_id]['post_id'] != $forum_topic_data['topic_last_post_id']...
Code: Select all
$sql = "SELECT MAX(post_id) AS last_post, MIN(post_id) AS first_post, COUNT(post_id) AS total_posts
FROM " . POSTS_TABLE . "
WHERE topic_id = $id";
Code: Select all
case 'topic':
$sql = "SELECT COUNT(post_id) AS total_posts
FROM " . POSTS_TABLE . "
WHERE topic_id = $id";
if ( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, 'Could not get post ID', '', __LINE__, __FILE__, $sql);
$row = $db->sql_fetchrow($result);
$sql = "SELECT *
FROM " . POSTS_TABLE . "
WHERE topic_id = $id
ORDER BY post_time ASC
LIMIT 1";
if ( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, 'Could not get post ID', '', __LINE__, __FILE__, $sql);
$row_first = $db->sql_fetchrow($result);
$sql = "SELECT *
FROM " . POSTS_TABLE . "
WHERE topic_id = $id
ORDER BY post_time DESC
LIMIT 1";
if ( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, 'Could not get post ID', '', __LINE__, __FILE__, $sql);
$row_last = $db->sql_fetchrow($result);
if ($row_first && $row_last)
{
if ($row['total_posts'])
{
// Correct the details of this topic
//2.0.18: Added topic_poster and topic_time, adjusted id's
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_replies = ' . ($row['total_posts'] - 1) . ',
topic_first_post_id = ' . $row_first['post_id'] . ',
topic_poster = ' . $row_first['poster_id'] . ',
topic_time = ' . $row_first['post_time'] . ',
topic_last_post_id = ' . $row_last['post_id'] . '
WHERE topic_id = ' . $id;
if (!$db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not update topic', '', __LINE__, __FILE__, $sql);
}
}
else
{
// There are no replies to this topic
// Check if it is a move stub
$sql = 'SELECT topic_moved_id
FROM ' . TOPICS_TABLE . "
WHERE topic_id = $id";
if (!($result = $db->sql_query($sql)))
{
message_die(GENERAL_ERROR, 'Could not get topic ID', '', __LINE__, __FILE__, $sql);
}
if ($row = $db->sql_fetchrow($result))
{
if (!$row['topic_moved_id'])
{
$sql = 'DELETE FROM ' . TOPICS_TABLE . " WHERE topic_id = $id";
if (!$db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not remove topic', '', __LINE__, __FILE__, $sql);
}
}
}
$db->sql_freeresult($result);
}
//End of 2.0.18 update
}
break;
Merlin Sythove wrote:asinshesq wrote:Viewtopic executes a sync when the last_post_id is no longer the last post by timestamp.
Not quite: in viewtopic a sync is executed if the actual last post on the last page of a topic, is not the same one as listed as the last post in the database. So the ID's must be identical, but there is nothing to indicate that it has anything to do with the time.