From 337dd98fd4b8ae93ba010ee127abc20f31aceb72 Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Wed, 24 Jul 2002 21:43:51 +0000 Subject: [PATCH] Fix missing group_id in upgrade, move fulltext search indexing to last operation ... it failing won't result in a half upgraded board git-svn-id: file:///svn/phpbb/branches/phpBB-2_0_0@2732 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/upgrade.php | 166 ++++++++++++++++++++++------------------------ 1 file changed, 80 insertions(+), 86 deletions(-) diff --git a/phpBB/upgrade.php b/phpBB/upgrade.php index b98178e9aa..d9efa94e3c 100644 --- a/phpBB/upgrade.php +++ b/phpBB/upgrade.php @@ -812,24 +812,16 @@ if ( !empty($next) ) $per_pct = ceil( $db->sql_numrows($result) / 40 ); $inc = 0; + $group_id = 1; while( $row = $db->sql_fetchrow($result) ) { - $sql = "INSERT INTO " . GROUPS_TABLE . " (group_name, group_description, group_single_user) - VALUES ('" . addslashes($row['username']) . "', 'Personal User', 1)"; + $sql = "INSERT INTO " . GROUPS_TABLE . " (group_id, group_name, group_description, group_single_user) + VALUES ($group_id, '" . addslashes($row['username']) . "', 'Personal User', 1)"; query($sql, "Wasn't able to insert user ".$row['user_id']." into table ".GROUPS_TABLE); - $group_id = $db->sql_nextid(); - - if ( $group_id != 0 ) - { - $sql = "INSERT INTO " . USER_GROUP_TABLE . " (group_id, user_id, user_pending) - VALUES ($group_id, " . $row['user_id'] . ", 0)"; - query($sql, "Wasn't able to insert user ".$row['user_id']." into table ".USER_GROUP_TABLE); - } - else - { - print "Couldn't get insert ID for " . GROUPS_TABLE . " table
\n"; - } + $sql = "INSERT INTO " . USER_GROUP_TABLE . " (group_id, user_id, user_pending) + VALUES ($group_id, " . $row['user_id'] . ", 0)"; + query($sql, "Wasn't able to insert user ".$row['user_id']." into table ".USER_GROUP_TABLE); if ( is_int($row['user_regdate']) ) { @@ -837,6 +829,8 @@ if ( !empty($next) ) continue; } + $group_id++; + // // Nathan's bbcode2 conversion // @@ -1630,77 +1624,6 @@ if ( !empty($next) ) } print " OK
\n"; - end_step('fulltext_search_indexing'); - - case 'fulltext_search_indexing': - // - // Generate search word list - // - // Fetch a batch of posts_text entries - // - $sql = "SELECT COUNT(*) as total, MAX(post_id) as max_post_id - FROM " . POSTS_TEXT_TABLE; - $result = query($sql, "Couldn't get post count totals"); - - $max_post_id = $db->sql_fetchrow($result); - - $totalposts = $max_post_id['total']; - $max_post_id = $max_post_id['max_post_id']; - $per_percent = round(( $totalposts / 500 ) * 10); - - $postcounter = ( !isset($HTTP_GET_VARS['batchstart']) ) ? 0 : $HTTP_GET_VARS['batchstart']; - - $batchsize = 150; // Process this many posts per loop - $batchcount = 0; - $total_percent = 0; - - for(;$postcounter <= $max_post_id; $postcounter += $batchsize) - { - $batchstart = $postcounter + 1; - $batchend = $postcounter + $batchsize; - $batchcount++; - - print " * Fulltext Indexing ( $batchstart to $batchend ) :: "; - flush(); - - $sql = "SELECT * - FROM " . POSTS_TEXT_TABLE ." - WHERE post_id - BETWEEN $batchstart - AND $batchend"; - $posts_result = query($sql, "Couldn't obtain post_text"); - - $per_pct = ceil( $db->sql_numrows($posts_result) / 40 ); - $inc = 0; - - if ( $row = $db->sql_fetchrow($posts_result) ) - { - do - { - add_search_words($row['post_id'], $row['post_text'], $row['post_subject']); - - $inc++; - if ( $inc == $per_pct ) - { - print "."; - flush(); - $inc = 0; - } - } - while( $row = $db->sql_fetchrow($posts_result) ); - } - - $db->sql_freeresult($posts_result); - - // Remove common words after the first 2 batches and after every 4th batch after that. - if ( $batchcount % 4 == 3 ) - { - remove_common('global', 0.4); - } - - print " OK
\n"; - } - end_step('update_topics'); case 'update_topics': @@ -1930,6 +1853,77 @@ if ( !empty($next) ) print "OK
\n"; } + end_step('fulltext_search_indexing'); + + case 'fulltext_search_indexing': + // + // Generate search word list + // + // Fetch a batch of posts_text entries + // + $sql = "SELECT COUNT(*) as total, MAX(post_id) as max_post_id + FROM " . POSTS_TEXT_TABLE; + $result = query($sql, "Couldn't get post count totals"); + + $max_post_id = $db->sql_fetchrow($result); + + $totalposts = $max_post_id['total']; + $max_post_id = $max_post_id['max_post_id']; + $per_percent = round(( $totalposts / 500 ) * 10); + + $postcounter = ( !isset($HTTP_GET_VARS['batchstart']) ) ? 0 : $HTTP_GET_VARS['batchstart']; + + $batchsize = 150; // Process this many posts per loop + $batchcount = 0; + $total_percent = 0; + + for(;$postcounter <= $max_post_id; $postcounter += $batchsize) + { + $batchstart = $postcounter + 1; + $batchend = $postcounter + $batchsize; + $batchcount++; + + print " * Fulltext Indexing ( $batchstart to $batchend ) :: "; + flush(); + + $sql = "SELECT * + FROM " . POSTS_TEXT_TABLE ." + WHERE post_id + BETWEEN $batchstart + AND $batchend"; + $posts_result = query($sql, "Couldn't obtain post_text"); + + $per_pct = ceil( $db->sql_numrows($posts_result) / 40 ); + $inc = 0; + + if ( $row = $db->sql_fetchrow($posts_result) ) + { + do + { + add_search_words($row['post_id'], $row['post_text'], $row['post_subject']); + + $inc++; + if ( $inc == $per_pct ) + { + print "."; + flush(); + $inc = 0; + } + } + while( $row = $db->sql_fetchrow($posts_result) ); + } + + $db->sql_freeresult($posts_result); + + // Remove common words after the first 2 batches and after every 4th batch after that. + if ( $batchcount % 4 == 3 ) + { + remove_common('global', 0.4); + } + + print " OK
\n"; + } + echo "\n

\n\nUPGRADE COMPLETED
\n"; } } @@ -1938,4 +1932,4 @@ print "
If the upgrade completed without error you may click +?> \ No newline at end of file