From b8c55291ed7ed86565be2bc651bf20eb1a9ed4dd Mon Sep 17 00:00:00 2001 From: Josh Woody Date: Thu, 17 Jun 2010 23:58:18 -0500 Subject: [feature/soft-delete] Lay the groundwork for a soft-delete feature So far, I've added no new functionality. The biggest change here is adjusting the DB column names to "visibility" rather than "approved". Some things here are pretty likely to change, for example the name and location of the topic_visibility class. Happy birthday phpBB :) PHPBB3-9657 --- phpBB/includes/functions_admin.php | 77 +++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 35 deletions(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 5e2ee8c8f6..328c8e9778 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -644,7 +644,7 @@ function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_s 'posts' => ($call_delete_posts) ? delete_posts($where_type, $where_ids, false, true, $post_count_sync, false) : 0, ); - $sql = 'SELECT topic_id, forum_id, topic_approved, topic_moved_id + $sql = 'SELECT topic_id, forum_id, topic_visibility, topic_moved_id FROM ' . TOPICS_TABLE . ' WHERE ' . $where_clause; $result = $db->sql_query($sql); @@ -654,7 +654,7 @@ function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_s $forum_ids[] = $row['forum_id']; $topic_ids[] = $row['topic_id']; - if ($row['topic_approved'] && !$row['topic_moved_id']) + if ($row['topic_visibility'] == ITEM_APPROVED && !$row['topic_moved_id']) { $approved_topics++; } @@ -767,7 +767,7 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = $approved_posts = 0; $post_ids = $topic_ids = $forum_ids = $post_counts = $remove_topics = array(); - $sql = 'SELECT post_id, poster_id, post_approved, post_postcount, topic_id, forum_id + $sql = 'SELECT post_id, poster_id, post_visibility, post_postcount, topic_id, forum_id FROM ' . POSTS_TABLE . ' WHERE ' . $where_clause; $result = $db->sql_query($sql); @@ -779,12 +779,12 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = $topic_ids[] = (int) $row['topic_id']; $forum_ids[] = (int) $row['forum_id']; - if ($row['post_postcount'] && $post_count_sync && $row['post_approved']) + if ($row['post_postcount'] && $post_count_sync && $row['post_visibility'] == ITEM_APPROVED) { $post_counts[$row['poster_id']] = (!empty($post_counts[$row['poster_id']])) ? $post_counts[$row['poster_id']] + 1 : 1; } - if ($row['post_approved']) + if ($row['post_visibility'] == ITEM_APPROVED) { $approved_posts++; } @@ -1274,7 +1274,7 @@ function phpbb_unlink($filename, $mode = 'file', $entry_removed = false) * - forum Resync complete forum * - topic Resync topics * - topic_moved Removes topic shadows that would be in the same forum as the topic they link to -* - topic_approved Resyncs the topic_approved flag according to the status of the first post +* - topic_visibility Resyncs the topic_visibility flag according to the status of the first post * - post_reported Resyncs the post_reported flag, relying on actual reports * - topic_reported Resyncs the topic_reported flag, relying on post_reported flags * - post_attachement Same as post_reported, but with attachment flags @@ -1294,7 +1294,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $where_ids = ($where_ids) ? array((int) $where_ids) : array(); } - if ($mode == 'forum' || $mode == 'topic' || $mode == 'topic_approved' || $mode == 'topic_reported' || $mode == 'post_reported') + if ($mode == 'forum' || $mode == 'topic' || $mode == 'topic_visibility' || $mode == 'topic_reported' || $mode == 'post_reported') { if (!$where_type) { @@ -1380,7 +1380,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $db->sql_transaction('commit'); break; - case 'topic_approved': + case 'topic_visibility': $db->sql_transaction('begin'); switch ($db->sql_layer) @@ -1388,22 +1388,22 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, case 'mysql4': case 'mysqli': $sql = 'UPDATE ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p - SET t.topic_approved = p.post_approved + SET t.topic_visibility = p.post_visibility $where_sql_and t.topic_first_post_id = p.post_id"; $db->sql_query($sql); break; default: - $sql = 'SELECT t.topic_id, p.post_approved + $sql = 'SELECT t.topic_id, p.post_visibility FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p $where_sql_and p.post_id = t.topic_first_post_id - AND p.post_approved <> t.topic_approved"; + AND p.post_visibility <> t.topic_visibility"; $result = $db->sql_query($sql); $topic_ids = array(); while ($row = $db->sql_fetchrow($result)) { - $topic_ids[] = $row['topic_id']; + $topic_ids[$row['topic_id']] = $row['post_visibility']; } $db->sql_freeresult($result); @@ -1412,10 +1412,13 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, return; } - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_approved = 1 - topic_approved - WHERE ' . $db->sql_in_set('topic_id', $topic_ids); - $db->sql_query($sql); + foreach ($topic_ids as $topic_id => $visibility) + { + $sql = 'UPDATE ' . TOPICS_TABLE . ' + SET topic_visibility = ' . $visibility . ' + WHERE topic_id' . $topic_id; + $db->sql_query($sql); + } break; } @@ -1680,10 +1683,10 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, // 2: Get topic counts for each forum (optional) if ($sync_extra) { - $sql = 'SELECT forum_id, topic_approved, COUNT(topic_id) AS forum_topics + $sql = 'SELECT forum_id, topic_visibility, COUNT(topic_id) AS forum_topics FROM ' . TOPICS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $forum_ids) . ' - GROUP BY forum_id, topic_approved'; + GROUP BY forum_id, topic_visibility'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) @@ -1691,7 +1694,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $forum_id = (int) $row['forum_id']; $forum_data[$forum_id]['topics_real'] += $row['forum_topics']; - if ($row['topic_approved']) + if ($row['topic_visibility'] == ITEM_APPROVED) { $forum_data[$forum_id]['topics'] = $row['forum_topics']; } @@ -1707,7 +1710,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $sql = 'SELECT SUM(t.topic_replies + 1) AS forum_posts FROM ' . TOPICS_TABLE . ' t WHERE ' . $db->sql_in_set('t.forum_id', $forum_ids) . ' - AND t.topic_approved = 1 + AND t.topic_visibility = ' . ITEM_APPROVED . ' AND t.topic_status <> ' . ITEM_MOVED; } else @@ -1715,7 +1718,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $sql = 'SELECT t.forum_id, SUM(t.topic_replies + 1) AS forum_posts FROM ' . TOPICS_TABLE . ' t WHERE ' . $db->sql_in_set('t.forum_id', $forum_ids) . ' - AND t.topic_approved = 1 + AND t.topic_visibility = ' . ITEM_APPROVED . ' AND t.topic_status <> ' . ITEM_MOVED . ' GROUP BY t.forum_id'; } @@ -1737,14 +1740,14 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $sql = 'SELECT MAX(t.topic_last_post_id) as last_post_id FROM ' . TOPICS_TABLE . ' t WHERE ' . $db->sql_in_set('t.forum_id', $forum_ids) . ' - AND t.topic_approved = 1'; + AND t.topic_visibility = ' . ITEM_APPROVED; } else { $sql = 'SELECT t.forum_id, MAX(t.topic_last_post_id) as last_post_id FROM ' . TOPICS_TABLE . ' t WHERE ' . $db->sql_in_set('t.forum_id', $forum_ids) . ' - AND t.topic_approved = 1 + AND t.topic_visibility = ' . ITEM_APPROVED . ' GROUP BY t.forum_id'; } @@ -1846,7 +1849,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $db->sql_transaction('begin'); - $sql = 'SELECT t.topic_id, t.forum_id, t.topic_moved_id, t.topic_approved, ' . (($sync_extra) ? 't.topic_attachment, t.topic_reported, ' : '') . 't.topic_poster, t.topic_time, t.topic_replies, t.topic_replies_real, t.topic_first_post_id, t.topic_first_poster_name, t.topic_first_poster_colour, t.topic_last_post_id, t.topic_last_post_subject, t.topic_last_poster_id, t.topic_last_poster_name, t.topic_last_poster_colour, t.topic_last_post_time + $sql = 'SELECT t.topic_id, t.forum_id, t.topic_moved_id, t.topic_visibility, ' . (($sync_extra) ? 't.topic_attachment, t.topic_reported, ' : '') . 't.topic_poster, t.topic_time, t.topic_replies, t.topic_replies_real, t.topic_first_post_id, t.topic_first_poster_name, t.topic_first_poster_colour, t.topic_last_post_id, t.topic_last_post_subject, t.topic_last_poster_id, t.topic_last_poster_name, t.topic_last_poster_colour, t.topic_last_post_time FROM ' . TOPICS_TABLE . " t $where_sql"; $result = $db->sql_query($sql); @@ -1880,10 +1883,10 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, // Use "t" as table alias because of the $where_sql clause // NOTE: 't.post_approved' in the GROUP BY is causing a major slowdown. - $sql = 'SELECT t.topic_id, t.post_approved, COUNT(t.post_id) AS total_posts, MIN(t.post_id) AS first_post_id, MAX(t.post_id) AS last_post_id + $sql = 'SELECT t.topic_id, t.post_visibility, COUNT(t.post_id) AS total_posts, MIN(t.post_id) AS first_post_id, MAX(t.post_id) AS last_post_id FROM ' . POSTS_TABLE . " t $where_sql - GROUP BY t.topic_id, t.post_approved"; + GROUP BY t.topic_id, t.post_visibility"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) @@ -1907,7 +1910,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $topic_data[$topic_id]['replies_real'] += $row['total_posts']; $topic_data[$topic_id]['first_post_id'] = (!$topic_data[$topic_id]['first_post_id']) ? $row['first_post_id'] : min($topic_data[$topic_id]['first_post_id'], $row['first_post_id']); - if ($row['post_approved'] || !$topic_data[$topic_id]['last_post_id']) + if ($row['post_visibility'] || !$topic_data[$topic_id]['last_post_id']) { $topic_data[$topic_id]['replies'] = $row['total_posts'] - 1; $topic_data[$topic_id]['last_post_id'] = $row['last_post_id']; @@ -1952,7 +1955,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, unset($delete_topics, $delete_topic_ids); } - $sql = 'SELECT p.post_id, p.topic_id, p.post_approved, p.poster_id, p.post_subject, p.post_username, p.post_time, u.username, u.user_colour + $sql = 'SELECT p.post_id, p.topic_id, p.post_visibility, p.poster_id, p.post_subject, p.post_username, p.post_time, u.username, u.user_colour FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u WHERE ' . $db->sql_in_set('p.post_id', $post_ids) . ' AND u.user_id = p.poster_id'; @@ -1965,9 +1968,9 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, if ($row['post_id'] == $topic_data[$topic_id]['first_post_id']) { - if ($topic_data[$topic_id]['topic_approved'] != $row['post_approved']) + if ($topic_data[$topic_id]['topic_visibility'] != $row['post_visibility']) { - $approved_unapproved_ids[] = $topic_id; + $approved_unapproved_ids[$topic_id] = $row['post_visibility']; } $topic_data[$topic_id]['time'] = $row['post_time']; $topic_data[$topic_id]['poster'] = $row['poster_id']; @@ -2029,7 +2032,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $sync_shadow_topics = array(); if (sizeof($post_ids)) { - $sql = 'SELECT p.post_id, p.topic_id, p.post_approved, p.poster_id, p.post_subject, p.post_username, p.post_time, u.username, u.user_colour + $sql = 'SELECT p.post_id, p.topic_id, p.post_visibility, p.poster_id, p.post_subject, p.post_username, p.post_time, u.username, u.user_colour FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u WHERE ' . $db->sql_in_set('p.post_id', $post_ids) . ' AND u.user_id = p.poster_id'; @@ -2099,10 +2102,14 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, // approved becomes unapproved, and vice-versa if (sizeof($approved_unapproved_ids)) { - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_approved = 1 - topic_approved - WHERE ' . $db->sql_in_set('topic_id', $approved_unapproved_ids); - $db->sql_query($sql); + foreach ($approved_unapproved_ids as $update_topic_id => $status) + { + // @TODO: Consider grouping by $status and only running 3 queries + $sql = 'UPDATE ' . TOPICS_TABLE . ' + SET topic_visibility = ' . $status . ' + WHERE topic_id = ' . $update_topic_id; + $db->sql_query($sql); + } } unset($approved_unapproved_ids); -- cgit v1.2.1 From c03d692a98fafa921a832e063c76a3d844632ca7 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 30 Aug 2012 22:57:00 +0200 Subject: [feature/soft-delete] Fix some more usages of _approved column names PHPBB3-9657 --- phpBB/includes/functions_admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 328c8e9778..54130df935 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -1882,7 +1882,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $db->sql_freeresult($result); // Use "t" as table alias because of the $where_sql clause - // NOTE: 't.post_approved' in the GROUP BY is causing a major slowdown. + // NOTE: 't.post_visibility' in the GROUP BY is causing a major slowdown. $sql = 'SELECT t.topic_id, t.post_visibility, COUNT(t.post_id) AS total_posts, MIN(t.post_id) AS first_post_id, MAX(t.post_id) AS last_post_id FROM ' . POSTS_TABLE . " t $where_sql -- cgit v1.2.1 From 5b64ebc11d10b66212661282a4dcfd411d038211 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 2 Oct 2012 15:34:18 +0200 Subject: [feature/soft-delete] Fix a bug in sync() and set_post_visibility() PHPBB3-9657 --- phpBB/includes/functions_admin.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 54130df935..bb8b02bbea 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -1908,12 +1908,12 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, unset($delete_topics[$topic_id]); $topic_data[$topic_id]['replies_real'] += $row['total_posts']; - $topic_data[$topic_id]['first_post_id'] = (!$topic_data[$topic_id]['first_post_id']) ? $row['first_post_id'] : min($topic_data[$topic_id]['first_post_id'], $row['first_post_id']); - if ($row['post_visibility'] || !$topic_data[$topic_id]['last_post_id']) + if ($row['post_visibility'] == ITEM_APPROVED) { - $topic_data[$topic_id]['replies'] = $row['total_posts'] - 1; + $topic_data[$topic_id]['first_post_id'] = $row['first_post_id']; $topic_data[$topic_id]['last_post_id'] = $row['last_post_id']; + $topic_data[$topic_id]['replies'] = $row['total_posts'] - 1; } } } -- cgit v1.2.1 From 63d11c976b0bcef68ce4809c8c76124451df88ea Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 5 Oct 2012 12:37:01 +0200 Subject: [feature/soft-delete] Fix sync('topic') to match the new logic This also fixes set_post_visibility() PHPBB3-9567 --- phpBB/includes/functions_admin.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index bb8b02bbea..04c99b5e62 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -1889,6 +1889,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, GROUP BY t.topic_id, t.post_visibility"; $result = $db->sql_query($sql); + $topic_firstlast_data = array(); while ($row = $db->sql_fetchrow($result)) { $topic_id = (int) $row['topic_id']; @@ -1911,10 +1912,19 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, if ($row['post_visibility'] == ITEM_APPROVED) { + $topic_firstlast_data[$topic_id]['visibility'] = ITEM_APPROVED; $topic_data[$topic_id]['first_post_id'] = $row['first_post_id']; $topic_data[$topic_id]['last_post_id'] = $row['last_post_id']; $topic_data[$topic_id]['replies'] = $row['total_posts'] - 1; } + else if (!isset($topic_firstlast_data[$topic_id]['visibility']) || $topic_firstlast_data[$topic_id]['visibility'] != ITEM_APPROVED) + { + // If there is no approved post, we take the min/max of the other visibilities + // for the last and first post info, because it is only visible to moderators anyway + $topic_data[$topic_id]['first_post_id'] = (!empty($topic_data[$topic_id]['first_post_id'])) ? min($topic_data[$topic_id]['first_post_id'], $row['first_post_id']) : $row['first_post_id']; + $topic_data[$topic_id]['last_post_id'] = max($topic_data[$topic_id]['last_post_id'], $row['last_post_id']); + $topic_firstlast_data[$topic_id]['visibility'] = $row['post_visibility']; + } } } $db->sql_freeresult($result); -- cgit v1.2.1 From 224be5bc4f7ffdf6f22c3da3aff94fb7a3d7571f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 9 Oct 2012 14:02:42 +0200 Subject: [feature/soft-delete] Fix sync('topic_visibility') The function can not rely on the first post anymore, as that one could be soft deleted but the topic still has approved replies which are still visible. PHPBB3-9567 --- phpBB/includes/functions_admin.php | 73 +++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 32 deletions(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 04c99b5e62..0a351aa6e8 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -1383,43 +1383,52 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, case 'topic_visibility': $db->sql_transaction('begin'); - switch ($db->sql_layer) + + $sql = 'SELECT t.topic_id, p.post_visibility + FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p + $where_sql_and p.topic_id = t.topic_id + AND p.post_visibility = " . ITEM_APPROVED; + $result = $db->sql_query($sql); + + $topics_approved = array(); + while ($row = $db->sql_fetchrow($result)) { - case 'mysql4': - case 'mysqli': - $sql = 'UPDATE ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p - SET t.topic_visibility = p.post_visibility - $where_sql_and t.topic_first_post_id = p.post_id"; - $db->sql_query($sql); - break; + $topics_approved[] = (int) $row['topic_id']; + } + $db->sql_freeresult($result); - default: - $sql = 'SELECT t.topic_id, p.post_visibility - FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p - $where_sql_and p.post_id = t.topic_first_post_id - AND p.post_visibility <> t.topic_visibility"; - $result = $db->sql_query($sql); + $sql = 'SELECT t.topic_id, p.post_visibility + FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p + $where_sql_and " . $db->sql_in_set('t.topic_id', $topics_approved, true, true) . ' + AND p.topic_id = t.topic_id + AND p.post_visibility = ' . ITEM_DELETED; + $result = $db->sql_query($sql); - $topic_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $topic_ids[$row['topic_id']] = $row['post_visibility']; - } - $db->sql_freeresult($result); + $topics_softdeleted = array(); + while ($row = $db->sql_fetchrow($result)) + { + $topics_softdeleted[] = (int) $row['topic_id']; + } + $db->sql_freeresult($result); - if (!sizeof($topic_ids)) - { - return; - } + $topics_softdeleted = array_diff($topics_softdeleted, $topics_approved); + $topics_not_unapproved = array_merge($topics_softdeleted, $topics_approved); - foreach ($topic_ids as $topic_id => $visibility) - { - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_visibility = ' . $visibility . ' - WHERE topic_id' . $topic_id; - $db->sql_query($sql); - } - break; + $update_ary = array( + ITEM_UNAPPROVED => (!empty($topics_not_unapproved)) ? $where_sql_and . ' ' . $db->sql_in_set('topic_id', $topics_not_unapproved, true) : '', + ITEM_APPROVED => (!empty($topics_approved)) ? ' WHERE ' . $db->sql_in_set('topic_id', $topics_approved) : '', + ITEM_DELETED => (!empty($topics_softdeleted)) ? ' WHERE ' . $db->sql_in_set('topic_id', $topics_softdeleted) : '', + ); + + foreach ($topic_visiblities as $visibility => $sql_where) + { + if ($sql_where) + { + $sql = 'UPDATE ' . TOPICS_TABLE . ' + SET topic_visibility = ' . $visibility . ' + ' . $sql_where; + $db->sql_query($sql); + } } $db->sql_transaction('commit'); -- cgit v1.2.1 From fbf85b76c15c27e478f24947098d56c8c4bb3435 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 9 Oct 2012 15:38:50 +0200 Subject: [feature/soft-delete] Correctly synchronize the topic_visibility in sync() This also makes sync('topic_visibility') obsolete, but we keep it for now. Also fix a unit test, because ITEM_DELETED overpowers ITEM_UNAPPROVED PHPBB3-9567 --- phpBB/includes/functions_admin.php | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 0a351aa6e8..cb84d1cfb1 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -1854,7 +1854,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, break; case 'topic': - $topic_data = $post_ids = $approved_unapproved_ids = $resync_forums = $delete_topics = $delete_posts = $moved_topics = array(); + $topic_data = $post_ids = $resync_forums = $delete_topics = $delete_posts = $moved_topics = array(); $db->sql_transaction('begin'); @@ -1873,6 +1873,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $topic_id = (int) $row['topic_id']; $topic_data[$topic_id] = $row; + $topic_data[$topic_id]['visibility'] = ITEM_UNAPPROVED; $topic_data[$topic_id]['replies_real'] = -1; $topic_data[$topic_id]['replies'] = 0; $topic_data[$topic_id]['first_post_id'] = 0; @@ -1898,7 +1899,6 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, GROUP BY t.topic_id, t.post_visibility"; $result = $db->sql_query($sql); - $topic_firstlast_data = array(); while ($row = $db->sql_fetchrow($result)) { $topic_id = (int) $row['topic_id']; @@ -1921,18 +1921,23 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, if ($row['post_visibility'] == ITEM_APPROVED) { - $topic_firstlast_data[$topic_id]['visibility'] = ITEM_APPROVED; + $topic_data[$topic_id]['visibility'] = ITEM_APPROVED; $topic_data[$topic_id]['first_post_id'] = $row['first_post_id']; $topic_data[$topic_id]['last_post_id'] = $row['last_post_id']; $topic_data[$topic_id]['replies'] = $row['total_posts'] - 1; } - else if (!isset($topic_firstlast_data[$topic_id]['visibility']) || $topic_firstlast_data[$topic_id]['visibility'] != ITEM_APPROVED) + else if ($topic_data[$topic_id]['visibility'] != ITEM_APPROVED) { // If there is no approved post, we take the min/max of the other visibilities // for the last and first post info, because it is only visible to moderators anyway $topic_data[$topic_id]['first_post_id'] = (!empty($topic_data[$topic_id]['first_post_id'])) ? min($topic_data[$topic_id]['first_post_id'], $row['first_post_id']) : $row['first_post_id']; $topic_data[$topic_id]['last_post_id'] = max($topic_data[$topic_id]['last_post_id'], $row['last_post_id']); - $topic_firstlast_data[$topic_id]['visibility'] = $row['post_visibility']; + + if ($topic_data[$topic_id]['visibility'] == ITEM_UNAPPROVED) + { + // Soft delete status is stronger than unapproved. + $topic_data[$topic_id]['visibility'] = $row['post_visibility']; + } } } } @@ -1987,10 +1992,6 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, if ($row['post_id'] == $topic_data[$topic_id]['first_post_id']) { - if ($topic_data[$topic_id]['topic_visibility'] != $row['post_visibility']) - { - $approved_unapproved_ids[$topic_id] = $row['post_visibility']; - } $topic_data[$topic_id]['time'] = $row['post_time']; $topic_data[$topic_id]['poster'] = $row['poster_id']; $topic_data[$topic_id]['first_poster_name'] = ($row['poster_id'] == ANONYMOUS) ? $row['post_username'] : $row['username']; @@ -2118,22 +2119,8 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, unset($sync_shadow_topics, $shadow_topic_data); } - // approved becomes unapproved, and vice-versa - if (sizeof($approved_unapproved_ids)) - { - foreach ($approved_unapproved_ids as $update_topic_id => $status) - { - // @TODO: Consider grouping by $status and only running 3 queries - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_visibility = ' . $status . ' - WHERE topic_id = ' . $update_topic_id; - $db->sql_query($sql); - } - } - unset($approved_unapproved_ids); - // These are fields that will be synchronised - $fieldnames = array('time', 'replies', 'replies_real', 'poster', 'first_post_id', 'first_poster_name', 'first_poster_colour', 'last_post_id', 'last_post_subject', 'last_post_time', 'last_poster_id', 'last_poster_name', 'last_poster_colour'); + $fieldnames = array('time', 'visibility', 'replies', 'replies_real', 'poster', 'first_post_id', 'first_poster_name', 'first_poster_colour', 'last_post_id', 'last_post_subject', 'last_post_time', 'last_poster_id', 'last_poster_name', 'last_poster_colour'); if ($sync_extra) { -- cgit v1.2.1 From 168dd29f24843e97182c894a5d43a7d38f8a195c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 22 Oct 2012 14:21:44 +0200 Subject: [feature/soft-delete] Fix sync() and some more functions to use the new fields PHPBB3-9567 --- phpBB/includes/functions_admin.php | 49 ++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 13 deletions(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index cb84d1cfb1..a38fa2a70f 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -1670,8 +1670,11 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, if ($sync_extra) { $forum_data[$forum_id]['posts'] = 0; + $forum_data[$forum_id]['posts_unapproved'] = 0; + $forum_data[$forum_id]['posts_softdeleted'] = 0; $forum_data[$forum_id]['topics'] = 0; - $forum_data[$forum_id]['topics_real'] = 0; + $forum_data[$forum_id]['topics_unapproved'] = 0; + $forum_data[$forum_id]['topics_softdeleted'] = 0; } $forum_data[$forum_id]['last_post_id'] = 0; $forum_data[$forum_id]['last_post_subject'] = ''; @@ -1692,7 +1695,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, // 2: Get topic counts for each forum (optional) if ($sync_extra) { - $sql = 'SELECT forum_id, topic_visibility, COUNT(topic_id) AS forum_topics + $sql = 'SELECT forum_id, topic_visibility, COUNT(topic_id) AS total_topics FROM ' . TOPICS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $forum_ids) . ' GROUP BY forum_id, topic_visibility'; @@ -1701,11 +1704,18 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, while ($row = $db->sql_fetchrow($result)) { $forum_id = (int) $row['forum_id']; - $forum_data[$forum_id]['topics_real'] += $row['forum_topics']; if ($row['topic_visibility'] == ITEM_APPROVED) { - $forum_data[$forum_id]['topics'] = $row['forum_topics']; + $forum_data[$forum_id]['topics'] = $row['total_topics']; + } + else if ($row['topic_visibility'] == ITEM_UNAPPROVED) + { + $forum_data[$forum_id]['topics_unapproved'] = $row['total_topics']; + } + else if ($row['topic_visibility'] == ITEM_DELETED) + { + $forum_data[$forum_id]['topics_softdeleted'] = $row['total_topics']; } } $db->sql_freeresult($result); @@ -1716,7 +1726,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, { if (sizeof($forum_ids) == 1) { - $sql = 'SELECT SUM(t.topic_replies + 1) AS forum_posts + $sql = 'SELECT SUM(t.topic_posts) AS forum_posts, SUM(t.topic_posts_unapproved) AS forum_posts_unapproved, SUM(t.topic_posts_softdeleted) AS forum_posts_softdeleted FROM ' . TOPICS_TABLE . ' t WHERE ' . $db->sql_in_set('t.forum_id', $forum_ids) . ' AND t.topic_visibility = ' . ITEM_APPROVED . ' @@ -1724,7 +1734,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, } else { - $sql = 'SELECT t.forum_id, SUM(t.topic_replies + 1) AS forum_posts + $sql = 'SELECT t.forum_id, SUM(t.topic_posts) AS forum_posts, SUM(t.topic_posts_unapproved) AS forum_posts_unapproved, SUM(t.topic_posts_softdeleted) AS forum_posts_softdeleted FROM ' . TOPICS_TABLE . ' t WHERE ' . $db->sql_in_set('t.forum_id', $forum_ids) . ' AND t.topic_visibility = ' . ITEM_APPROVED . ' @@ -1739,6 +1749,8 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $forum_id = (sizeof($forum_ids) == 1) ? (int) $forum_ids[0] : (int) $row['forum_id']; $forum_data[$forum_id]['posts'] = (int) $row['forum_posts']; + $forum_data[$forum_id]['posts_unapproved'] = (int) $row['forum_posts_unapproved']; + $forum_data[$forum_id]['posts_softdeleted'] = (int) $row['forum_posts_softdeleted']; } $db->sql_freeresult($result); } @@ -1819,7 +1831,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, if ($sync_extra) { - array_push($fieldnames, 'posts', 'topics', 'topics_real'); + array_push($fieldnames, 'posts', 'posts_unapproved', 'posts_softdeleted', 'topics', 'topics_unapproved', 'topics_softdeleted'); } foreach ($forum_data as $forum_id => $row) @@ -1858,7 +1870,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $db->sql_transaction('begin'); - $sql = 'SELECT t.topic_id, t.forum_id, t.topic_moved_id, t.topic_visibility, ' . (($sync_extra) ? 't.topic_attachment, t.topic_reported, ' : '') . 't.topic_poster, t.topic_time, t.topic_replies, t.topic_replies_real, t.topic_first_post_id, t.topic_first_poster_name, t.topic_first_poster_colour, t.topic_last_post_id, t.topic_last_post_subject, t.topic_last_poster_id, t.topic_last_poster_name, t.topic_last_poster_colour, t.topic_last_post_time + $sql = 'SELECT t.topic_id, t.forum_id, t.topic_moved_id, t.topic_visibility, ' . (($sync_extra) ? 't.topic_attachment, t.topic_reported, ' : '') . 't.topic_poster, t.topic_time, t.topic_posts, t.topic_posts_unapproved, t.topic_posts_softdeleted, t.topic_first_post_id, t.topic_first_poster_name, t.topic_first_poster_colour, t.topic_last_post_id, t.topic_last_post_subject, t.topic_last_poster_id, t.topic_last_poster_name, t.topic_last_poster_colour, t.topic_last_post_time FROM ' . TOPICS_TABLE . " t $where_sql"; $result = $db->sql_query($sql); @@ -1874,8 +1886,9 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $topic_id = (int) $row['topic_id']; $topic_data[$topic_id] = $row; $topic_data[$topic_id]['visibility'] = ITEM_UNAPPROVED; - $topic_data[$topic_id]['replies_real'] = -1; - $topic_data[$topic_id]['replies'] = 0; + $topic_data[$topic_id]['posts'] = 0; + $topic_data[$topic_id]['posts_unapproved'] = 0; + $topic_data[$topic_id]['posts_softdeleted'] = 0; $topic_data[$topic_id]['first_post_id'] = 0; $topic_data[$topic_id]['last_post_id'] = 0; unset($topic_data[$topic_id]['topic_id']); @@ -1917,14 +1930,24 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, // When we'll be done, only topics with no posts will remain unset($delete_topics[$topic_id]); - $topic_data[$topic_id]['replies_real'] += $row['total_posts']; + if ($row['post_visibility'] == ITEM_APPROVED) + { + $topic_data[$topic_id]['posts'] = $row['total_posts']; + } + else if ($row['post_visibility'] == ITEM_UNAPPROVED) + { + $topic_data[$topic_id]['posts_unapproved'] = $row['total_posts']; + } + else if ($row['post_visibility'] == ITEM_DELETED) + { + $topic_data[$topic_id]['posts_softdeleted'] = $row['total_posts']; + } if ($row['post_visibility'] == ITEM_APPROVED) { $topic_data[$topic_id]['visibility'] = ITEM_APPROVED; $topic_data[$topic_id]['first_post_id'] = $row['first_post_id']; $topic_data[$topic_id]['last_post_id'] = $row['last_post_id']; - $topic_data[$topic_id]['replies'] = $row['total_posts'] - 1; } else if ($topic_data[$topic_id]['visibility'] != ITEM_APPROVED) { @@ -2120,7 +2143,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, } // These are fields that will be synchronised - $fieldnames = array('time', 'visibility', 'replies', 'replies_real', 'poster', 'first_post_id', 'first_poster_name', 'first_poster_colour', 'last_post_id', 'last_post_subject', 'last_post_time', 'last_poster_id', 'last_poster_name', 'last_poster_colour'); + $fieldnames = array('time', 'visibility', 'posts', 'posts_unapproved', 'posts_softdeleted', 'poster', 'first_post_id', 'first_poster_name', 'first_poster_colour', 'last_post_id', 'last_post_subject', 'last_post_time', 'last_poster_id', 'last_poster_name', 'last_poster_colour'); if ($sync_extra) { -- cgit v1.2.1 From b3d5f2b4e42404610f5db8dda25859db942fd60e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 23 Oct 2012 23:37:25 +0200 Subject: [feature/soft-delete] Fix unit tests for delete_posts() PHPBB3-9567 --- phpBB/includes/functions_admin.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index a38fa2a70f..e2a133270b 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -1729,7 +1729,6 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $sql = 'SELECT SUM(t.topic_posts) AS forum_posts, SUM(t.topic_posts_unapproved) AS forum_posts_unapproved, SUM(t.topic_posts_softdeleted) AS forum_posts_softdeleted FROM ' . TOPICS_TABLE . ' t WHERE ' . $db->sql_in_set('t.forum_id', $forum_ids) . ' - AND t.topic_visibility = ' . ITEM_APPROVED . ' AND t.topic_status <> ' . ITEM_MOVED; } else @@ -1737,7 +1736,6 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $sql = 'SELECT t.forum_id, SUM(t.topic_posts) AS forum_posts, SUM(t.topic_posts_unapproved) AS forum_posts_unapproved, SUM(t.topic_posts_softdeleted) AS forum_posts_softdeleted FROM ' . TOPICS_TABLE . ' t WHERE ' . $db->sql_in_set('t.forum_id', $forum_ids) . ' - AND t.topic_visibility = ' . ITEM_APPROVED . ' AND t.topic_status <> ' . ITEM_MOVED . ' GROUP BY t.forum_id'; } -- cgit v1.2.1 From 63e3baf0eb37d1d8f6f0b5b46df56a673eafa6fe Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 2 Nov 2012 12:40:10 +0100 Subject: [feature/soft-delete] Correctly manage softdeleting via posting.php PHPBB3-9567 --- phpBB/includes/functions_admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index e2a133270b..f1c3cf62b1 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -881,7 +881,7 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = sync('forum', 'forum_id', $forum_ids, true, true); } - if ($approved_posts) + if ($approved_posts && $post_count_sync) { set_config_count('num_posts', $approved_posts * (-1), true); } -- cgit v1.2.1 From 9c2a58eff4c2bd164ee3bdb2ec66729d4562963d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 9 Nov 2012 13:37:53 +0100 Subject: [feature/soft-delete] Append _approved to *_posts and *_topics column names PHPBB3-9567 --- phpBB/includes/functions_admin.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index f1c3cf62b1..2bf36d967a 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -1669,10 +1669,10 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $forum_data[$forum_id] = $row; if ($sync_extra) { - $forum_data[$forum_id]['posts'] = 0; + $forum_data[$forum_id]['posts_approved'] = 0; $forum_data[$forum_id]['posts_unapproved'] = 0; $forum_data[$forum_id]['posts_softdeleted'] = 0; - $forum_data[$forum_id]['topics'] = 0; + $forum_data[$forum_id]['topics_approved'] = 0; $forum_data[$forum_id]['topics_unapproved'] = 0; $forum_data[$forum_id]['topics_softdeleted'] = 0; } @@ -1746,7 +1746,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, { $forum_id = (sizeof($forum_ids) == 1) ? (int) $forum_ids[0] : (int) $row['forum_id']; - $forum_data[$forum_id]['posts'] = (int) $row['forum_posts']; + $forum_data[$forum_id]['posts_approved'] = (int) $row['forum_posts']; $forum_data[$forum_id]['posts_unapproved'] = (int) $row['forum_posts_unapproved']; $forum_data[$forum_id]['posts_softdeleted'] = (int) $row['forum_posts_softdeleted']; } @@ -1829,7 +1829,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, if ($sync_extra) { - array_push($fieldnames, 'posts', 'posts_unapproved', 'posts_softdeleted', 'topics', 'topics_unapproved', 'topics_softdeleted'); + array_push($fieldnames, 'posts_approved', 'posts_unapproved', 'posts_softdeleted', 'topics_approved', 'topics_unapproved', 'topics_softdeleted'); } foreach ($forum_data as $forum_id => $row) @@ -1884,7 +1884,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $topic_id = (int) $row['topic_id']; $topic_data[$topic_id] = $row; $topic_data[$topic_id]['visibility'] = ITEM_UNAPPROVED; - $topic_data[$topic_id]['posts'] = 0; + $topic_data[$topic_id]['posts_approved'] = 0; $topic_data[$topic_id]['posts_unapproved'] = 0; $topic_data[$topic_id]['posts_softdeleted'] = 0; $topic_data[$topic_id]['first_post_id'] = 0; @@ -1930,7 +1930,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, if ($row['post_visibility'] == ITEM_APPROVED) { - $topic_data[$topic_id]['posts'] = $row['total_posts']; + $topic_data[$topic_id]['posts_approved'] = $row['total_posts']; } else if ($row['post_visibility'] == ITEM_UNAPPROVED) { @@ -2141,7 +2141,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, } // These are fields that will be synchronised - $fieldnames = array('time', 'visibility', 'posts', 'posts_unapproved', 'posts_softdeleted', 'poster', 'first_post_id', 'first_poster_name', 'first_poster_colour', 'last_post_id', 'last_post_subject', 'last_post_time', 'last_poster_id', 'last_poster_name', 'last_poster_colour'); + $fieldnames = array('time', 'visibility', 'posts_approved', 'posts_unapproved', 'posts_softdeleted', 'poster', 'first_post_id', 'first_poster_name', 'first_poster_colour', 'last_post_id', 'last_post_subject', 'last_post_time', 'last_poster_id', 'last_poster_name', 'last_poster_colour'); if ($sync_extra) { -- cgit v1.2.1 From f77a6eaab5485329a3b13922649fb8902e6e397f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 10 Nov 2012 11:24:52 +0100 Subject: [feature/soft-delete] Fix the rest of *_approved and the delete_post unit test PHPBB3-9567 --- phpBB/includes/functions_admin.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 2bf36d967a..5cbe234347 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -1707,7 +1707,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, if ($row['topic_visibility'] == ITEM_APPROVED) { - $forum_data[$forum_id]['topics'] = $row['total_topics']; + $forum_data[$forum_id]['topics_approved'] = $row['total_topics']; } else if ($row['topic_visibility'] == ITEM_UNAPPROVED) { @@ -1726,14 +1726,14 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, { if (sizeof($forum_ids) == 1) { - $sql = 'SELECT SUM(t.topic_posts) AS forum_posts, SUM(t.topic_posts_unapproved) AS forum_posts_unapproved, SUM(t.topic_posts_softdeleted) AS forum_posts_softdeleted + $sql = 'SELECT SUM(t.topic_posts_approved) AS forum_posts_approved, SUM(t.topic_posts_unapproved) AS forum_posts_unapproved, SUM(t.topic_posts_softdeleted) AS forum_posts_softdeleted FROM ' . TOPICS_TABLE . ' t WHERE ' . $db->sql_in_set('t.forum_id', $forum_ids) . ' AND t.topic_status <> ' . ITEM_MOVED; } else { - $sql = 'SELECT t.forum_id, SUM(t.topic_posts) AS forum_posts, SUM(t.topic_posts_unapproved) AS forum_posts_unapproved, SUM(t.topic_posts_softdeleted) AS forum_posts_softdeleted + $sql = 'SELECT t.forum_id, SUM(t.topic_posts_approved) AS forum_posts_approved, SUM(t.topic_posts_unapproved) AS forum_posts_unapproved, SUM(t.topic_posts_softdeleted) AS forum_posts_softdeleted FROM ' . TOPICS_TABLE . ' t WHERE ' . $db->sql_in_set('t.forum_id', $forum_ids) . ' AND t.topic_status <> ' . ITEM_MOVED . ' @@ -1746,7 +1746,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, { $forum_id = (sizeof($forum_ids) == 1) ? (int) $forum_ids[0] : (int) $row['forum_id']; - $forum_data[$forum_id]['posts_approved'] = (int) $row['forum_posts']; + $forum_data[$forum_id]['posts_approved'] = (int) $row['forum_posts_approved']; $forum_data[$forum_id]['posts_unapproved'] = (int) $row['forum_posts_unapproved']; $forum_data[$forum_id]['posts_softdeleted'] = (int) $row['forum_posts_softdeleted']; } @@ -1868,7 +1868,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $db->sql_transaction('begin'); - $sql = 'SELECT t.topic_id, t.forum_id, t.topic_moved_id, t.topic_visibility, ' . (($sync_extra) ? 't.topic_attachment, t.topic_reported, ' : '') . 't.topic_poster, t.topic_time, t.topic_posts, t.topic_posts_unapproved, t.topic_posts_softdeleted, t.topic_first_post_id, t.topic_first_poster_name, t.topic_first_poster_colour, t.topic_last_post_id, t.topic_last_post_subject, t.topic_last_poster_id, t.topic_last_poster_name, t.topic_last_poster_colour, t.topic_last_post_time + $sql = 'SELECT t.topic_id, t.forum_id, t.topic_moved_id, t.topic_visibility, ' . (($sync_extra) ? 't.topic_attachment, t.topic_reported, ' : '') . 't.topic_poster, t.topic_time, t.topic_posts_approved, t.topic_posts_unapproved, t.topic_posts_softdeleted, t.topic_first_post_id, t.topic_first_poster_name, t.topic_first_poster_colour, t.topic_last_post_id, t.topic_last_post_subject, t.topic_last_poster_id, t.topic_last_poster_name, t.topic_last_poster_colour, t.topic_last_post_time FROM ' . TOPICS_TABLE . " t $where_sql"; $result = $db->sql_query($sql); -- cgit v1.2.1 From 9e845d4641aa7f71ab713434a7a2e1edfd2876b4 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 3 Jul 2013 15:31:40 +0200 Subject: [ticket/11619] Use HTTP/1.0 because of lack of chunked-encoding handling. PHPBB3-11619 --- phpBB/includes/functions_admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index a9d1db24a5..2f73858ea2 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -3121,7 +3121,7 @@ function get_remote_file($host, $directory, $filename, &$errstr, &$errno, $port if ($fsock = @fsockopen($host, $port, $errno, $errstr, $timeout)) { - @fputs($fsock, "GET $directory/$filename HTTP/1.1\r\n"); + @fputs($fsock, "GET $directory/$filename HTTP/1.0\r\n"); @fputs($fsock, "HOST: $host\r\n"); @fputs($fsock, "Connection: close\r\n\r\n"); -- cgit v1.2.1