diff --git a/phpBB/db/schemas/mssql_schema.sql b/phpBB/db/schemas/mssql_schema.sql
index 8cc34abcdb..dc1495dc76 100644
--- a/phpBB/db/schemas/mssql_schema.sql
+++ b/phpBB/db/schemas/mssql_schema.sql
@@ -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]
diff --git a/phpBB/db/schemas/mysql_schema.sql b/phpBB/db/schemas/mysql_schema.sql
index b0dde05c34..83813f1309 100644
--- a/phpBB/db/schemas/mysql_schema.sql
+++ b/phpBB/db/schemas/mysql_schema.sql
@@ -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)
diff --git a/phpBB/db/schemas/oracle_schema.sql b/phpBB/db/schemas/oracle_schema.sql
index cbfc0e3139..99c10e0c37 100644
--- a/phpBB/db/schemas/oracle_schema.sql
+++ b/phpBB/db/schemas/oracle_schema.sql
@@ -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)
diff --git a/phpBB/db/schemas/postgres_schema.sql b/phpBB/db/schemas/postgres_schema.sql
index 5c912559e4..a4a2798d08 100644
--- a/phpBB/db/schemas/postgres_schema.sql
+++ b/phpBB/db/schemas/postgres_schema.sql
@@ -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)
diff --git a/phpBB/develop/convert_bbcodeuid.php b/phpBB/develop/convert_bbcodeuid.php
new file mode 100644
index 0000000000..9e2f959046
--- /dev/null
+++ b/phpBB/develop/convert_bbcodeuid.php
@@ -0,0 +1,82 @@
+sql_query($sql))
+ {
+ print "
\n";
+ print "$errormsg
";
+ $sql_error = $db->sql_error();
+ print $sql_error['code'] .": ". $sql_error['message']. "
\n";
+ print "$sql
";
+ print "\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.
";
+ exit;
+}
+
+
+$sql = "ALTER TABLE ".POSTS_TEXT_TABLE."
+ ADD bbcode_uid char(10) NOT NULL";
+print "Adding bbcode_uid field to ".POSTS_TEXT_TABLE.".
\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.
\n";
+for($i = 0; $i <= $maxid; $i += $batchsize)
+{
+ $batchstart = $i + 1;
+ $batchend = $i + $batchsize;
+
+ print "Moving BBcode UID in post number $batchstart to $batchend
\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 HERE to remove the bbcode_uid table from the POSTS table (if you didn't get any serious error messages).
"; + +$db->sql_close(); + +?> diff --git a/phpBB/posting.php b/phpBB/posting.php index 2fb140ee35..c6a70d5372 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -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); -?> \ No newline at end of file +?> diff --git a/phpBB/search.php b/phpBB/search.php index 2db6986e37..0c50dfda9d 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -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); -?> \ No newline at end of file +?> diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 93b8c7719c..8641e8ec39 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -383,7 +383,7 @@ $select_post_order .= ""; // // 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); -?> \ No newline at end of file +?>