-
Bug
-
Resolution: Fixed
-
Major
-
3.0.2
-
None
-
PHP Environment: 5.2.0
Database: MySQL 5.0.27
in functions_posting.php, when the first post of the topic is deleted, the first topic poster details are updated, yet not the topic time.
case 'delete_first_post':
|
$sql = 'SELECT p.post_id, p.poster_id, p.post_username, u.username, u.user_colour
|
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . " u
|
WHERE p.topic_id = $topic_id
|
AND p.poster_id = u.user_id
|
ORDER BY p.post_time ASC";
|
$result = $db->sql_query_limit($sql, 1);
|
$row = $db->sql_fetchrow($result);
|
$db->sql_freeresult($result);
|
|
if ($data['topic_type'] != POST_GLOBAL)
|
{
|
$sql_data[FORUMS_TABLE] = ($data['post_approved']) ? 'forum_posts = forum_posts - 1' : '';
|
}
|
|
$sql_data[TOPICS_TABLE] = 'topic_first_post_id = ' . intval($row['post_id']) . ", topic_first_poster_colour = '" . $db->sql_escape($row['user_colour']) . "', topic_first_poster_name = '" . (($row['poster_id'] == ANONYMOUS) ? $db->sql_escape($row['post_username']) : $db->sql_escape($row['username'])) . "'";
|
|
// Decrementing topic_replies here is fine because this case only happens if there is more than one post within the topic - basically removing one "reply"
|
$sql_data[TOPICS_TABLE] .= ', topic_replies_real = topic_replies_real - 1' . (($data['post_approved']) ? ', topic_replies = topic_replies - 1' : '');
|
|
$next_post_id = (int) $row['post_id'];
|
break;
|
in my opinion should rather be something like this
case 'delete_first_post':
|
$sql = 'SELECT p.post_id, p.poster_id, p.post_username, p.post_time, u.username, u.user_colour
|
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . " u
|
WHERE p.topic_id = $topic_id
|
AND p.poster_id = u.user_id
|
ORDER BY p.post_time ASC";
|
$result = $db->sql_query_limit($sql, 1);
|
$row = $db->sql_fetchrow($result);
|
$db->sql_freeresult($result);
|
|
if ($data['topic_type'] != POST_GLOBAL)
|
{
|
$sql_data[FORUMS_TABLE] = ($data['post_approved']) ? 'forum_posts = forum_posts - 1' : '';
|
}
|
|
$sql_data[TOPICS_TABLE] = 'topic_first_post_id = ' . intval($row['post_id']) . ", topic_first_poster_colour = '" . $db->sql_escape($row['user_colour']) . "', topic_first_poster_name = '" . (($row['poster_id'] == ANONYMOUS) ? $db->sql_escape($row['post_username']) : $db->sql_escape($row['username'])) . "', topic_time = " . (int) $row['post_time'];
|
|
// Decrementing topic_replies here is fine because this case only happens if there is more than one post within the topic - basically removing one "reply"
|
$sql_data[TOPICS_TABLE] .= ', topic_replies_real = topic_replies_real - 1' . (($data['post_approved']) ? ', topic_replies = topic_replies - 1' : '');
|
|
$next_post_id = (int) $row['post_id'];
|
break;
|