From 7cffec58d0db3cbed6f6e55785d3accd89efe8aa Mon Sep 17 00:00:00 2001
From: Henry Sudhof
Date: Wed, 23 May 2007 15:05:46 +0000
Subject: [PATCH] This probably broke things :| #10697 #11421 #11555 #11421
git-svn-id: file:///svn/phpbb/trunk@7666 89ea8834-ac86-4346-8a33-228a782c2dd0
---
phpBB/docs/CHANGELOG.html | 6 ++
phpBB/includes/functions_convert.php | 21 +++++
.../install/convertors/functions_phpbb20.php | 10 +-
phpBB/install/database_update.php | 34 ++++++-
phpBB/install/install_convert.php | 91 ++++++++++++++++++-
phpBB/language/en/install.php | 2 +
6 files changed, 159 insertions(+), 5 deletions(-)
diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html
index c56fa29653..eaad188e45 100644
--- a/phpBB/docs/CHANGELOG.html
+++ b/phpBB/docs/CHANGELOG.html
@@ -194,6 +194,12 @@ p a {
[Fix] Imageset editor more friendly (Bug #11511)
[Fix] Made Custom BBCode validation more strict (Bug #11335)
[Fix] Proper sync of data on topic copy (Bug #11335)
+ [Fix] Introduced ORDER BY clauses to converter queries (Bug #10697)
+ [Fix] added a sync to post counts during conversion (Bug #11421)
+ [Fix] Stopped bots from getting added to the registered users group during conversion(Bug #11283)
+ [Fix] Filled "SMILIEYS_DISABLED" template variable (Bug #11257)
+ [Fix] Properly escaped the delimiter in disallowed username comparisons (Bug #11339)
+ [Fix] Check global purge setting (Bug #11555)
diff --git a/phpBB/includes/functions_convert.php b/phpBB/includes/functions_convert.php
index 98c1452c23..5da10236c2 100644
--- a/phpBB/includes/functions_convert.php
+++ b/phpBB/includes/functions_convert.php
@@ -1707,6 +1707,27 @@ function add_default_groups()
}
}
+
+/**
+* Sync post count. We might need to do this in batches.
+*/
+function sync_post_count($offset, $limit)
+{
+ global $db;
+ $sql = 'SELECT COUNT(post_id) AS num_posts, poster_id
+ FROM ' . POSTS_TABLE . '
+ WHERE post_postcount = 1
+ GROUP BY poster_id
+ ORDER BY poster_id';
+ $result = $db->sql_query_limit($sql, $limit, $offset);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $db->sql_query('UPDATE ' . USERS_TABLE . " SET user_posts = {$row['num_posts']} WHERE user_id = {$row['poster_id']}");
+ }
+ $db->sql_freeresult($result);
+}
+
/**
* Add the search bots into the database
* This code should be used in execute_last if the source database did not have bots
diff --git a/phpBB/install/convertors/functions_phpbb20.php b/phpBB/install/convertors/functions_phpbb20.php
index 246316513d..badac08999 100644
--- a/phpBB/install/convertors/functions_phpbb20.php
+++ b/phpBB/install/convertors/functions_phpbb20.php
@@ -83,6 +83,14 @@ function phpbb_insert_forums()
$db->sql_query('SET IDENTITY_INSERT ' . FORUMS_TABLE . ' ON');
break;
}
+
+ // pruning disabled globally?
+ $sql = "SELECT config_value
+ FROM {$convert->src_table_prefix}config
+ WHERE config_name = 'prune_enable'";
+ $result = $src_db->sql_query($sql);
+ $prune_enabled = (int) $src_db->sql_fetchfield('config_value');
+ $src_db->sql_freeresult($result);
$cats_added = array();
while ($row = $src_db->sql_fetchrow($result))
@@ -206,7 +214,7 @@ function phpbb_insert_forums()
'forum_desc' => htmlspecialchars(phpbb_set_default_encoding($row['forum_desc']), ENT_COMPAT, 'UTF-8'),
'forum_type' => FORUM_POST,
'forum_status' => is_item_locked($row['forum_status']),
- 'enable_prune' => $row['prune_enable'],
+ 'enable_prune' => ($prune_enabled) ? $row['prune_enable'] : 0,
'prune_next' => null_to_zero($row['prune_next']),
'prune_days' => null_to_zero($row['prune_days']),
'prune_viewed' => 0,
diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php
index 194bb5600a..9996d0ce96 100644
--- a/phpBB/install/database_update.php
+++ b/phpBB/install/database_update.php
@@ -8,7 +8,7 @@
*
*/
-$updates_to_version = '3.0.RC1';
+$updates_to_version = '3.0.RC2';
if (defined('IN_PHPBB') && defined('IN_INSTALL'))
{
@@ -1151,6 +1151,38 @@ if (version_compare($current_version, '3.0.b5', '<='))
$no_updates = false;
}
+if (version_compare($current_version, '3.0.RC1', '<='))
+{
+ // we have to remove a few extra entries from converted boards.
+ $sql = 'SELECT group_id
+ FROM ' . GROUPS_TABLE . "
+ WHERE group_name = '" . $db->sql_escape('BOTS') . "'";
+ $result = $db->sql_query($sql);
+ $bot_group_id = (int) $db->sql_fetchfield('group_id');
+ $db->sql_freeresult($result);
+
+ $bots = array();
+ $sql = 'SELECT u.user_id
+ FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . ' ug
+ WHERE ug.group_id = ' . $bot_group_id . '
+ AND ug.user_id = u.user_id';
+ $result = $db->sql_query($sql);
+
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $bots[] = (int)$row['user_id'];
+ }
+ $db->sql_freeresult($result);
+
+ if (sizeof($bots))
+ {
+ $sql = 'DELETE FROM ' . USER_GROUP_TABLE . "
+ WHERE group_id <> $bot_group_id
+ AND " . $db->sql_in_set('user_id', $bots);
+ $db->sql_query($sql);
+ }
+}
_write_result($no_updates, $errored, $error_ary);
diff --git a/phpBB/install/install_convert.php b/phpBB/install/install_convert.php
index c0129e3c29..69ca75c9da 100644
--- a/phpBB/install/install_convert.php
+++ b/phpBB/install/install_convert.php
@@ -783,8 +783,16 @@ class install_convert extends module
$jump = request_var('jump', 0);
$final_jump = request_var('final_jump', 0);
$sync_batch = request_var('sync_batch', -1);
+ $sync_post_count = request_var('sync_post_count', -1);
$last_statement = request_var('last', 0);
+ // We are running sync...
+ if ($sync_post_count >= 0)
+ {
+ $this->sync_user_posts($sync_post_count);
+ return;
+ }
+
// We are running sync...
if ($sync_batch >= 0)
{
@@ -1163,6 +1171,12 @@ class install_convert extends module
$sql .= (!empty($schema['having'])) ? "\nHAVING " . $schema['having'] : '';
// Order By
+
+ if (empty($schema['order_by']) && !empty($schema['primary']))
+ {
+ $schema['order_by'] = $schema['primary'];
+ }
+
$sql .= (!empty($schema['order_by'])) ? "\nORDER BY " . $schema['order_by'] : '';
// Counting basically holds the amount of rows processed.
@@ -1398,6 +1412,78 @@ class install_convert extends module
return;
}
+ /**
+ * Sync function being executed at the middle, some functions need to be executed after a successful sync.
+ */
+ function sync_user_posts($sync_batch)
+ {
+ global $db, $template, $user;
+ global $convert;
+
+ $template->assign_block_vars('checks', array(
+ 'S_LEGEND' => true,
+ 'LEGEND' => $user->lang['SYNC_POST_COUNT'],
+ ));
+
+ $batch_size = $convert->batch_size;
+
+ $sql = 'SELECT COUNT(user_id) AS max_value
+ FROM ' . USERS_TABLE;
+ $result = $db->sql_query($sql);
+ $row = $db->sql_fetchrow($result);
+ $db->sql_freeresult($result);
+
+ // Set values of minimum/maximum primary value for this table.
+ $primary_min = 0;
+ $primary_max = $row['max_value'];
+
+ if ($sync_batch == 1)
+ {
+ $sync_batch = (int) $primary_min;
+ }
+ // Fetch a batch of rows, process and insert them.
+ while ($sync_batch <= $primary_max && still_on_time())
+ {
+ $end = ($sync_batch + $batch_size - 1);
+
+
+ $template->assign_block_vars('checks', array(
+ 'TITLE' => sprintf($user->lang['SYNC_POST_COUNT_ID'], $sync_batch, ($sync_batch + $batch_size)) . ((defined('DEBUG_EXTRA') && function_exists('memory_get_usage')) ? ' [' . ceil(memory_get_usage()/1024) . ' KB]' : ''),
+ 'RESULT' => $user->lang['DONE'],
+ ));
+
+ $sync_batch += $batch_size;
+ }
+
+ if ($sync_batch >= $primary_max)
+ {
+ sync_post_count($sync_batch, $batch_size);
+ $url = $this->save_convert_progress('&sync_batch=0');
+
+ $template->assign_vars(array(
+ 'L_SUBMIT' => $user->lang['CONTINUE_CONVERT'],
+ 'U_ACTION' => $url,
+ ));
+
+ $this->meta_refresh($url);
+ return;
+ }
+ else
+ {
+ $sync_batch--;
+ }
+
+ $url = $this->save_convert_progress('&sync_post_count=' . $sync_batch);
+
+ $template->assign_vars(array(
+ 'L_SUBMIT' => $user->lang['CONTINUE_CONVERT'],
+ 'U_ACTION' => $url,
+ ));
+
+ $this->meta_refresh($url);
+ return;
+ }
+
/**
* Sync function being executed at the middle, some functions need to be executed after a successful sync.
*/
@@ -1715,9 +1801,8 @@ class install_convert extends module
'RESULT' => $user->lang['DONE'],
));
- // Continue with synchronizing the forums...
- $url = $this->save_convert_progress('&sync_batch=0');
-
+ // Continue with synchronizing the post counts...
+ $url = $this->save_convert_progress('&sync_post_count=0');
$template->assign_vars(array(
'L_SUBMIT' => $user->lang['CONTINUE_CONVERT'],
'U_ACTION' => $url,
diff --git a/phpBB/language/en/install.php b/phpBB/language/en/install.php
index fa176cbaea..32a66ba62b 100755
--- a/phpBB/language/en/install.php
+++ b/phpBB/language/en/install.php
@@ -330,6 +330,8 @@ $lang = array_merge($lang, array(
// TODO: Write some text on obtaining support
'SUPPORT_BODY' => 'During the release candidate phase full support will be given at the phpBB 3.0.x support forums. We will provide answers to general setup questions, configuration problems, conversion problems and support for determining common problems mostly related to bugs. We also allow discussions about modifications and custom code/style additions.
For additional assistance, please refer to our Quick Start Guide and the online documentation.
To ensure you stay up to date with the latest news and releases, why not subscribe to our mailing list?',
'SYNC_FORUMS' => 'Starting to sync forums',
+ 'SYNC_POST_COUNT' => 'Synchronising post_counts',
+ 'SYNC_POST_COUNT_ID' => 'Synchronising post_counts from entry %1$s to %2$s.',
'SYNC_TOPICS' => 'Starting to sync topics',
'SYNC_TOPIC_ID' => 'Synchronising topics from topic_id %1$s to %2$s.',