mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
Finally moved the bbcode_uid from posts to posts_text, DON'T FORGET TO RUN THE CONVERT SCRIPT IN /develop/ !!
git-svn-id: file:///svn/phpbb/trunk@1436 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
92e5512011
commit
7eee52fff3
8 changed files with 99 additions and 17 deletions
|
@ -235,7 +235,6 @@ CREATE TABLE [phpbb_posts] (
|
|||
[enable_html] [smallint] NULL ,
|
||||
[enable_smilies] [smallint] NULL ,
|
||||
[enable_sig] [smallint] NULL ,
|
||||
[bbcode_uid] [char] (10) NULL ,
|
||||
[post_edit_time] [int] NULL ,
|
||||
[post_edit_count] [smallint] NULL
|
||||
) ON [PRIMARY]
|
||||
|
@ -243,6 +242,7 @@ GO
|
|||
|
||||
CREATE TABLE [phpbb_posts_text] (
|
||||
[post_id] [int] NOT NULL ,
|
||||
[bbcode_uid] [char] (10) NULL ,
|
||||
[post_subject] [varchar] (100) NULL ,
|
||||
[post_text] [text] NULL
|
||||
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
|
||||
|
|
|
@ -176,7 +176,6 @@ CREATE TABLE phpbb_posts (
|
|||
enable_html tinyint(1) DEFAULT '0' NOT NULL,
|
||||
enable_smilies tinyint(1) DEFAULT '1' NOT NULL,
|
||||
enable_sig tinyint(1) DEFAULT '1' NOT NULL,
|
||||
bbcode_uid char(10) NOT NULL,
|
||||
post_edit_time int(11),
|
||||
post_edit_count smallint(5) UNSIGNED DEFAULT '0' NOT NULL,
|
||||
PRIMARY KEY (post_id),
|
||||
|
@ -194,6 +193,7 @@ CREATE TABLE phpbb_posts (
|
|||
DROP TABLE IF EXISTS phpbb_posts_text;
|
||||
CREATE TABLE phpbb_posts_text (
|
||||
post_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
|
||||
bbcode_uid char(10) NOT NULL,
|
||||
post_subject varchar(255),
|
||||
post_text text,
|
||||
PRIMARY KEY (post_id)
|
||||
|
|
|
@ -198,7 +198,6 @@ CREATE TABLE phpbb_posts (
|
|||
enable_html number(4) DEFAULT '0' NOT NULL,
|
||||
enable_smilies number(4) DEFAULT '1' NOT NULL,
|
||||
enable_sig number(4) DEFAULT '1' NOT NULL,
|
||||
bbcode_uid varchar(10) DEFAULT '',
|
||||
post_edit_time number(11),
|
||||
post_edit_count number(4) DEFAULT '0' NOT NULL,
|
||||
CONSTRAINT phpbb_posts_pkey PRIMARY KEY (post_id)
|
||||
|
@ -214,6 +213,7 @@ CREATE INDEX topic_id_phpbb_posts_index ON phpbb_posts (topic_id);
|
|||
-------------------------------------------------------- */
|
||||
CREATE TABLE phpbb_posts_text (
|
||||
post_id number(4) DEFAULT '0' NOT NULL,
|
||||
bbcode_uid varchar(10) DEFAULT '',
|
||||
post_subject varchar(255),
|
||||
post_text varchar(2000),
|
||||
CONSTRAINT phpbb_posts_text_pkey PRIMARY KEY (post_id)
|
||||
|
|
|
@ -167,7 +167,6 @@ CREATE TABLE phpbb_posts (
|
|||
enable_html int2 DEFAULT '0' NOT NULL,
|
||||
enable_smilies int2 DEFAULT '1' NOT NULL,
|
||||
enable_sig int2 DEFAULT '1' NOT NULL,
|
||||
bbcode_uid varchar(10) DEFAULT '' NOT NULL,
|
||||
post_edit_time int4,
|
||||
post_edit_count int2 DEFAULT '0' NOT NULL,
|
||||
CONSTRAINT phpbb_posts_pkey PRIMARY KEY (post_id)
|
||||
|
@ -183,6 +182,7 @@ CREATE INDEX topic_id_phpbb_posts_index ON phpbb_posts (topic_id);
|
|||
-------------------------------------------------------- */
|
||||
CREATE TABLE phpbb_posts_text (
|
||||
post_id int4 DEFAULT '0' NOT NULL,
|
||||
bbcode_uid varchar(10) DEFAULT '' NOT NULL,
|
||||
post_subject varchar(255),
|
||||
post_text text,
|
||||
CONSTRAINT phpbb_posts_text_pkey PRIMARY KEY (post_id)
|
||||
|
|
82
phpBB/develop/convert_bbcodeuid.php
Normal file
82
phpBB/develop/convert_bbcodeuid.php
Normal file
|
@ -0,0 +1,82 @@
|
|||
<?php
|
||||
|
||||
$phpbb_root_path = "../";
|
||||
|
||||
include($phpbb_root_path . 'extension.inc');
|
||||
include($phpbb_root_path . 'config.'.$phpEx);
|
||||
include($phpbb_root_path . 'includes/constants.'.$phpEx);
|
||||
include($phpbb_root_path . 'includes/db.'.$phpEx);
|
||||
|
||||
function query($sql, $errormsg)
|
||||
{
|
||||
global $db;
|
||||
if(!$result = $db->sql_query($sql))
|
||||
{
|
||||
print "<br><font color=\"red\">\n";
|
||||
print "$errormsg<br>";
|
||||
$sql_error = $db->sql_error();
|
||||
print $sql_error['code'] .": ". $sql_error['message']. "<br>\n";
|
||||
print "<pre>$sql</pre>";
|
||||
print "</font>\n";
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
if($HTTP_GET_VARS['delete'] == 'true')
|
||||
{
|
||||
$sql = "ALTER TABLE ".POSTS_TABLE."
|
||||
DROP bbcode_uid";
|
||||
query($sql, "Didn't manage to drop the bbcode_uid table in ".POSTS_TABLE);
|
||||
print "All done now. Deleted the bbcode_uid column from the posts table.<p>";
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$sql = "ALTER TABLE ".POSTS_TEXT_TABLE."
|
||||
ADD bbcode_uid char(10) NOT NULL";
|
||||
print "Adding bbcode_uid field to ".POSTS_TEXT_TABLE.".<br>\n";
|
||||
$result = query($sql, "Couldn't get add bbcode_uid field to ".POSTS_TEXT_TABLE.".");
|
||||
|
||||
$sql = "
|
||||
SELECT
|
||||
count(*) as total,
|
||||
max(post_id) as maxid
|
||||
FROM ". POSTS_TABLE;
|
||||
$result = query($sql, "Couldn't get max post_id.");
|
||||
$maxid = $db->sql_fetchrow($result);
|
||||
$totalposts = $maxid['total'];
|
||||
$maxid = $maxid['maxid'];
|
||||
|
||||
$batchsize = 200;
|
||||
print "Going to convert BBcode in posts with $batchsize messages at a time and $totalposts in total.<br>\n";
|
||||
for($i = 0; $i <= $maxid; $i += $batchsize)
|
||||
{
|
||||
$batchstart = $i + 1;
|
||||
$batchend = $i + $batchsize;
|
||||
|
||||
print "Moving BBcode UID in post number $batchstart to $batchend<br>\n";
|
||||
flush();
|
||||
$sql = "
|
||||
SELECT
|
||||
post_id,
|
||||
bbcode_uid
|
||||
FROM "
|
||||
.POSTS_TABLE."
|
||||
WHERE
|
||||
post_id BETWEEN $batchstart AND $batchend";
|
||||
$result = query($sql, "Couldn't get ". POSTS_TABLE .".post_id $batchstart to $batchend");
|
||||
while($row = mysql_fetch_array($result))
|
||||
{
|
||||
query("UPDATE ".POSTS_TEXT_TABLE." set bbcode_uid = '". $row['bbcode_uid']. "' WHERE post_id = ".$row['post_id'], "Was unable to update the posts text table with the BBcode_uid");
|
||||
}
|
||||
}
|
||||
|
||||
echo "Click <a href=\"$PHP_SELF?delete=true\">HERE</a> to remove the bbcode_uid table from the POSTS table (if you didn't get any serious error messages).<p>";
|
||||
|
||||
$db->sql_close();
|
||||
|
||||
?>
|
|
@ -427,7 +427,7 @@ function topic_review($topic_id, $is_inline_review)
|
|||
//
|
||||
// Go ahead and pull all data for this topic
|
||||
//
|
||||
$sql = "SELECT u.username, u.user_id, p.*, pt.post_text, pt.post_subject
|
||||
$sql = "SELECT u.username, u.user_id, p.*, pt.post_text, pt.post_subject, pt.bbcode_uid
|
||||
FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt
|
||||
WHERE p.topic_id = $topic_id
|
||||
AND p.poster_id = u.user_id
|
||||
|
@ -1250,16 +1250,16 @@ if( ( $submit || $confirm || $mode == "delete" ) && !$error )
|
|||
$new_topic_id = $topic_id;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO " . POSTS_TABLE . " (topic_id, forum_id, poster_id, post_username, post_time, poster_ip, bbcode_uid, enable_bbcode, enable_html, enable_smilies, enable_sig)
|
||||
VALUES ($new_topic_id, $forum_id, " . $userdata['user_id'] . ", '$post_username', $current_time, '$user_ip', '$bbcode_uid', $bbcode_on, $html_on, $smilies_on, $attach_sig)";
|
||||
$sql = "INSERT INTO " . POSTS_TABLE . " (topic_id, forum_id, poster_id, post_username, post_time, poster_ip, enable_bbcode, enable_html, enable_smilies, enable_sig)
|
||||
VALUES ($new_topic_id, $forum_id, " . $userdata['user_id'] . ", '$post_username', $current_time, '$user_ip', $bbcode_on, $html_on, $smilies_on, $attach_sig)";
|
||||
$result = ($mode == "reply") ? $db->sql_query($sql, BEGIN_TRANSACTION) : $db->sql_query($sql);
|
||||
|
||||
if( $result )
|
||||
{
|
||||
$new_post_id = $db->sql_nextid();
|
||||
|
||||
$sql = "INSERT INTO " . POSTS_TEXT_TABLE . " (post_id, post_subject, post_text)
|
||||
VALUES ($new_post_id, '$post_subject', '$post_message')";
|
||||
$sql = "INSERT INTO " . POSTS_TEXT_TABLE . " (post_id, post_subject, bbcode_uid, post_text)
|
||||
VALUES ($new_post_id, '$post_subject', '$bbcode_uid', '$post_message')";
|
||||
|
||||
if( $db->sql_query($sql) )
|
||||
{
|
||||
|
@ -1865,12 +1865,12 @@ if( ( $submit || $confirm || $mode == "delete" ) && !$error )
|
|||
}
|
||||
|
||||
$sql = "UPDATE " . POSTS_TABLE . "
|
||||
SET bbcode_uid = '$bbcode_uid', enable_bbcode = $bbcode_on, enable_html = $html_on, enable_smilies = $smilies_on, enable_sig = $attach_sig" . $edited_sql . "
|
||||
SET enable_bbcode = $bbcode_on, enable_html = $html_on, enable_smilies = $smilies_on, enable_sig = $attach_sig" . $edited_sql . "
|
||||
WHERE post_id = $post_id";
|
||||
if($db->sql_query($sql))
|
||||
{
|
||||
$sql = "UPDATE " . POSTS_TEXT_TABLE . "
|
||||
SET post_text = '$post_message', post_subject = '$post_subject'
|
||||
SET post_text = '$post_message', bbcode_uid = '$bbcode_uid', post_subject = '$post_subject'
|
||||
WHERE post_id = $post_id";
|
||||
|
||||
if( $is_first_post_topic )
|
||||
|
@ -2308,7 +2308,7 @@ else
|
|||
else if( $mode == "editpost" || $mode == "quote" && ( !$preview && !$refresh ) )
|
||||
{
|
||||
|
||||
$sql = "SELECT p.*, pt.post_text, pt.post_subject, u.username, u.user_id, u.user_sig, t.topic_title, t.topic_type, t.topic_vote
|
||||
$sql = "SELECT p.*, pt.post_text, pt.post_subject, pt.bbcode_uid, u.username, u.user_id, u.user_sig, t.topic_title, t.topic_type, t.topic_vote
|
||||
FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . TOPICS_TABLE . " t, " . POSTS_TEXT_TABLE . " pt
|
||||
WHERE p.post_id = $post_id
|
||||
AND pt.post_id = p.post_id
|
||||
|
@ -2795,4 +2795,4 @@ $template->pparse("body");
|
|||
|
||||
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -649,7 +649,7 @@ else if( $query_keywords != "" || $query_author != "" || $search_id )
|
|||
|
||||
if( $show_results == "posts" )
|
||||
{
|
||||
$sql = "SELECT pt.post_text, pt.post_subject, p.*, f.forum_name, t.*, u.username, u.user_id, u.user_sig, u.user_sig_bbcode_uid
|
||||
$sql = "SELECT pt.post_text, pt.bbcode_uid, pt.post_subject, p.*, f.forum_name, t.*, u.username, u.user_id, u.user_sig, u.user_sig_bbcode_uid
|
||||
FROM " . FORUMS_TABLE . " f, " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TEXT_TABLE . " pt
|
||||
WHERE p.post_id IN ($search_results)
|
||||
AND pt.post_id = p.post_id
|
||||
|
@ -1191,4 +1191,4 @@ $template->pparse("body");
|
|||
|
||||
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -383,7 +383,7 @@ $select_post_order .= "</select>";
|
|||
//
|
||||
// Go ahead and pull all data for this topic
|
||||
//
|
||||
$sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_regdate, u.user_msnm, u.user_viewemail, u.user_rank, u.user_sig, u.user_sig_bbcode_uid, u.user_avatar, u.user_avatar_type, p.*, pt.post_text, pt.post_subject
|
||||
$sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_regdate, u.user_msnm, u.user_viewemail, u.user_rank, u.user_sig, u.user_sig_bbcode_uid, u.user_avatar, u.user_avatar_type, p.*, pt.post_text, pt.post_subject, pt.bbcode_uid
|
||||
FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt
|
||||
WHERE p.topic_id = $topic_id
|
||||
AND p.poster_id = u.user_id
|
||||
|
@ -1083,4 +1083,4 @@ $template->pparse("body");
|
|||
|
||||
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
Loading…
Add table
Reference in a new issue