mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 22:28:51 +00:00
- sync now correctly handles approved posts in unapproved topics (last_post info)
git-svn-id: file:///svn/phpbb/trunk@7191 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
59231a0024
commit
73ae601158
2 changed files with 36 additions and 19 deletions
|
@ -1481,18 +1481,22 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
|
||||||
// 3: Get post count and last_post_id for each forum
|
// 3: Get post count and last_post_id for each forum
|
||||||
if (sizeof($forum_ids) == 1)
|
if (sizeof($forum_ids) == 1)
|
||||||
{
|
{
|
||||||
$sql = 'SELECT COUNT(post_id) AS forum_posts, MAX(post_id) AS last_post_id
|
$sql = 'SELECT COUNT(p.post_id) AS forum_posts, MAX(p.post_id) AS last_post_id
|
||||||
FROM ' . POSTS_TABLE . '
|
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t
|
||||||
WHERE ' . $db->sql_in_set('forum_id', $forum_ids) . '
|
WHERE ' . $db->sql_in_set('p.forum_id', $forum_ids) . '
|
||||||
AND post_approved = 1';
|
AND p.topic_id = t.topic_id
|
||||||
|
AND t.topic_approved = 1
|
||||||
|
AND p.post_approved = 1';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$sql = 'SELECT forum_id, COUNT(post_id) AS forum_posts, MAX(post_id) AS last_post_id
|
$sql = 'SELECT forum_id, COUNT(p.post_id) AS forum_posts, MAX(p.post_id) AS last_post_id
|
||||||
FROM ' . POSTS_TABLE . '
|
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t
|
||||||
WHERE ' . $db->sql_in_set('forum_id', $forum_ids) . '
|
WHERE ' . $db->sql_in_set('p.forum_id', $forum_ids) . '
|
||||||
AND post_approved = 1
|
AND p.topic_id = t.topic_id
|
||||||
GROUP BY forum_id';
|
AND t.topic_approved = 1
|
||||||
|
AND p.post_approved = 1
|
||||||
|
GROUP BY p.forum_id';
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
|
|
|
@ -113,20 +113,33 @@ function update_post_information($type, $ids, $return_update_sql = false)
|
||||||
|
|
||||||
$update_sql = $empty_forums = $not_empty_forums = array();
|
$update_sql = $empty_forums = $not_empty_forums = array();
|
||||||
|
|
||||||
if (sizeof($ids) == 1)
|
if ($type != 'topic')
|
||||||
{
|
{
|
||||||
$sql = 'SELECT MAX(post_id) as last_post_id
|
$topic_join = ', ' . TOPICS_TABLE . ' t';
|
||||||
FROM ' . POSTS_TABLE . '
|
$topic_condition = 'AND t.topic_id = p.topic_id AND t.topic_approved = 1';
|
||||||
WHERE ' . $db->sql_in_set($type . '_id', $ids) . '
|
|
||||||
AND post_approved = 1';
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$sql = 'SELECT ' . $type . '_id, MAX(post_id) as last_post_id
|
$topic_join = '';
|
||||||
FROM ' . POSTS_TABLE . '
|
$topic_condition = '';
|
||||||
WHERE ' . $db->sql_in_set($type . '_id', $ids) . "
|
}
|
||||||
AND post_approved = 1
|
|
||||||
GROUP BY {$type}_id";
|
if (sizeof($ids) == 1)
|
||||||
|
{
|
||||||
|
$sql = 'SELECT MAX(p.post_id) as last_post_id
|
||||||
|
FROM ' . POSTS_TABLE . " p $topic_join
|
||||||
|
WHERE " . $db->sql_in_set('p.' . $type . '_id', $ids) . "
|
||||||
|
$topic_condition
|
||||||
|
AND p.post_approved = 1";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$sql = 'SELECT p.' . $type . '_id, MAX(p.post_id) as last_post_id
|
||||||
|
FROM ' . POSTS_TABLE . " p $topic_join
|
||||||
|
WHERE " . $db->sql_in_set('p.' . $type . '_id', $ids) . "
|
||||||
|
$topic_condition
|
||||||
|
AND p.post_approved = 1
|
||||||
|
GROUP BY p.{$type}_id";
|
||||||
}
|
}
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue