<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[BuddyPress][4391] trunk/bp-core/admin: Modifies schema queries to use the filtered bp_core_get_table_prefix().</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd>4391</dd>
<dt>Author</dt> <dd>boonebgorges</dd>
<dt>Date</dt> <dd>2011-05-19 17:01:39 +0000 (Thu, 19 May 2011)</dd>
</dl>

<h3>Log Message</h3>
<pre>Modifies schema queries to use the filtered bp_core_get_table_prefix(). Fixes #3228. Props wpmuguru</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpcoreadminbpcoreschemaphp">trunk/bp-core/admin/bp-core-schema.php</a></li>
<li><a href="#trunkbpcoreadminbpcoreupdatephp">trunk/bp-core/admin/bp-core-update.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpcoreadminbpcoreschemaphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/admin/bp-core-schema.php (4390 => 4391)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/admin/bp-core-schema.php        2011-05-19 16:08:09 UTC (rev 4390)
+++ trunk/bp-core/admin/bp-core-schema.php        2011-05-19 17:01:39 UTC (rev 4391)
</span><span class="lines">@@ -1,4 +1,6 @@
</span><span class="cx"> &lt;?php
</span><ins>+require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-functions.php' );

</ins><span class="cx"> function bp_core_set_charset() {
</span><span class="cx">         global $wpdb;
</span><span class="cx"> 
</span><span class="lines">@@ -15,8 +17,9 @@
</span><span class="cx">         global $wpdb;
</span><span class="cx"> 
</span><span class="cx">         $charset_collate = bp_core_set_charset();
</span><ins>+        $bp_prefix = bp_core_get_table_prefix();
</ins><span class="cx"> 
</span><del>-        $sql[] = &quot;CREATE TABLE {$wpdb-&gt;base_prefix}bp_notifications (
</del><ins>+        $sql[] = &quot;CREATE TABLE {$bp_prefix}bp_notifications (
</ins><span class="cx">                               id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
</span><span class="cx">                             user_id bigint(20) NOT NULL,
</span><span class="cx">                             item_id bigint(20) NOT NULL,
</span><span class="lines">@@ -41,8 +44,9 @@
</span><span class="cx">         global $wpdb;
</span><span class="cx"> 
</span><span class="cx">         $charset_collate = bp_core_set_charset();
</span><ins>+        $bp_prefix = bp_core_get_table_prefix();
</ins><span class="cx"> 
</span><del>-        $sql[] = &quot;CREATE TABLE {$wpdb-&gt;base_prefix}bp_activity (
</del><ins>+        $sql[] = &quot;CREATE TABLE {$bp_prefix}bp_activity (
</ins><span class="cx">                                   id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
</span><span class="cx">                                 user_id bigint(20) NOT NULL,
</span><span class="cx">                                 component varchar(75) NOT NULL,
</span><span class="lines">@@ -67,7 +71,7 @@
</span><span class="cx">                                 KEY hide_sitewide (hide_sitewide)
</span><span class="cx">                             ) {$charset_collate};&quot;;
</span><span class="cx"> 
</span><del>-        $sql[] = &quot;CREATE TABLE {$wpdb-&gt;base_prefix}bp_activity_meta (
</del><ins>+        $sql[] = &quot;CREATE TABLE {$bp_prefix}bp_activity_meta (
</ins><span class="cx">                                 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
</span><span class="cx">                                 activity_id bigint(20) NOT NULL,
</span><span class="cx">                                 meta_key varchar(255) DEFAULT NULL,
</span><span class="lines">@@ -83,8 +87,9 @@
</span><span class="cx">         global $wpdb;
</span><span class="cx"> 
</span><span class="cx">         $charset_collate = bp_core_set_charset();
</span><ins>+        $bp_prefix = bp_core_get_table_prefix();
</ins><span class="cx"> 
</span><del>-        $sql[] = &quot;CREATE TABLE {$wpdb-&gt;base_prefix}bp_friends (
</del><ins>+        $sql[] = &quot;CREATE TABLE {$bp_prefix}bp_friends (
</ins><span class="cx">                               id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
</span><span class="cx">                               initiator_user_id bigint(20) NOT NULL,
</span><span class="cx">                               friend_user_id bigint(20) NOT NULL,
</span><span class="lines">@@ -102,8 +107,9 @@
</span><span class="cx">         global $wpdb;
</span><span class="cx"> 
</span><span class="cx">         $charset_collate = bp_core_set_charset();
</span><ins>+        $bp_prefix = bp_core_get_table_prefix();
</ins><span class="cx"> 
</span><del>-        $sql[] = &quot;CREATE TABLE {$wpdb-&gt;base_prefix}bp_groups (
</del><ins>+        $sql[] = &quot;CREATE TABLE {$bp_prefix}bp_groups (
</ins><span class="cx">                                   id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
</span><span class="cx">                                 creator_id bigint(20) NOT NULL,
</span><span class="cx">                                   name varchar(100) NOT NULL,
</span><span class="lines">@@ -116,7 +122,7 @@
</span><span class="cx">                             KEY status (status)
</span><span class="cx">                             ) {$charset_collate};&quot;;
</span><span class="cx"> 
</span><del>-        $sql[] = &quot;CREATE TABLE {$wpdb-&gt;base_prefix}bp_groups_members (
</del><ins>+        $sql[] = &quot;CREATE TABLE {$bp_prefix}bp_groups_members (
</ins><span class="cx">                                   id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
</span><span class="cx">                                 group_id bigint(20) NOT NULL,
</span><span class="cx">                                 user_id bigint(20) NOT NULL,
</span><span class="lines">@@ -137,7 +143,7 @@
</span><span class="cx">                                 KEY is_confirmed (is_confirmed)
</span><span class="cx">                             ) {$charset_collate};&quot;;
</span><span class="cx"> 
</span><del>-        $sql[] = &quot;CREATE TABLE {$wpdb-&gt;base_prefix}bp_groups_groupmeta (
</del><ins>+        $sql[] = &quot;CREATE TABLE {$bp_prefix}bp_groups_groupmeta (
</ins><span class="cx">                                 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
</span><span class="cx">                                 group_id bigint(20) NOT NULL,
</span><span class="cx">                                 meta_key varchar(255) DEFAULT NULL,
</span><span class="lines">@@ -153,8 +159,9 @@
</span><span class="cx">         global $wpdb;
</span><span class="cx"> 
</span><span class="cx">         $charset_collate = bp_core_set_charset();
</span><ins>+        $bp_prefix = bp_core_get_table_prefix();
</ins><span class="cx"> 
</span><del>-        $sql[] = &quot;CREATE TABLE {$wpdb-&gt;base_prefix}bp_messages_messages (
</del><ins>+        $sql[] = &quot;CREATE TABLE {$bp_prefix}bp_messages_messages (
</ins><span class="cx">                                   id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
</span><span class="cx">                                   thread_id bigint(20) NOT NULL,
</span><span class="cx">                                   sender_id bigint(20) NOT NULL,
</span><span class="lines">@@ -165,7 +172,7 @@
</span><span class="cx">                             KEY thread_id (thread_id)
</span><span class="cx">                             ) {$charset_collate};&quot;;
</span><span class="cx"> 
</span><del>-        $sql[] = &quot;CREATE TABLE {$wpdb-&gt;base_prefix}bp_messages_recipients (
</del><ins>+        $sql[] = &quot;CREATE TABLE {$bp_prefix}bp_messages_recipients (
</ins><span class="cx">                                   id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
</span><span class="cx">                                   user_id bigint(20) NOT NULL,
</span><span class="cx">                                   thread_id bigint(20) NOT NULL,
</span><span class="lines">@@ -179,7 +186,7 @@
</span><span class="cx">                             KEY unread_count (unread_count)
</span><span class="cx">                             ) {$charset_collate};&quot;;
</span><span class="cx"> 
</span><del>-        $sql[] = &quot;CREATE TABLE {$wpdb-&gt;base_prefix}bp_messages_notices (
</del><ins>+        $sql[] = &quot;CREATE TABLE {$bp_prefix}bp_messages_notices (
</ins><span class="cx">                                   id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
</span><span class="cx">                                   subject varchar(200) NOT NULL,
</span><span class="cx">                                   message longtext NOT NULL,
</span><span class="lines">@@ -195,11 +202,12 @@
</span><span class="cx">         global $wpdb;
</span><span class="cx"> 
</span><span class="cx">         $charset_collate = bp_core_set_charset();
</span><ins>+        $bp_prefix = bp_core_get_table_prefix();
</ins><span class="cx"> 
</span><span class="cx">         update_site_option( 'bp-xprofile-base-group-name', _x( 'Base', 'First XProfile group name', 'buddypress' ) );
</span><span class="cx">         update_site_option( 'bp-xprofile-fullname-field-name', _x( 'Name', 'XProfile fullname field name', 'buddypress' ) );
</span><span class="cx"> 
</span><del>-        $sql[] = &quot;CREATE TABLE {$wpdb-&gt;base_prefix}bp_xprofile_groups (
</del><ins>+        $sql[] = &quot;CREATE TABLE {$bp_prefix}bp_xprofile_groups (
</ins><span class="cx">                             id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
</span><span class="cx">                             name varchar(150) NOT NULL,
</span><span class="cx">                             description mediumtext NOT NULL,
</span><span class="lines">@@ -208,7 +216,7 @@
</span><span class="cx">                             KEY can_delete (can_delete)
</span><span class="cx">                            ) {$charset_collate};&quot;;
</span><span class="cx"> 
</span><del>-        $sql[] = &quot;CREATE TABLE {$wpdb-&gt;base_prefix}bp_xprofile_fields (
</del><ins>+        $sql[] = &quot;CREATE TABLE {$bp_prefix}bp_xprofile_fields (
</ins><span class="cx">                             id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
</span><span class="cx">                             group_id bigint(20) unsigned NOT NULL,
</span><span class="cx">                             parent_id bigint(20) unsigned NOT NULL,
</span><span class="lines">@@ -228,7 +236,7 @@
</span><span class="cx">                             KEY is_required (is_required)
</span><span class="cx">                            ) {$charset_collate};&quot;;
</span><span class="cx"> 
</span><del>-        $sql[] = &quot;CREATE TABLE {$wpdb-&gt;base_prefix}bp_xprofile_data (
</del><ins>+        $sql[] = &quot;CREATE TABLE {$bp_prefix}bp_xprofile_data (
</ins><span class="cx">                             id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
</span><span class="cx">                             field_id bigint(20) unsigned NOT NULL,
</span><span class="cx">                             user_id bigint(20) unsigned NOT NULL,
</span><span class="lines">@@ -238,7 +246,7 @@
</span><span class="cx">                             KEY user_id (user_id)
</span><span class="cx">                            ) {$charset_collate};&quot;;
</span><span class="cx"> 
</span><del>-        $sql[] = &quot;CREATE TABLE {$wpdb-&gt;base_prefix}bp_xprofile_meta (
</del><ins>+        $sql[] = &quot;CREATE TABLE {$bp_prefix}bp_xprofile_meta (
</ins><span class="cx">                                 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
</span><span class="cx">                                 object_id bigint(20) NOT NULL,
</span><span class="cx">                                 object_type varchar(150) NOT NULL,
</span><span class="lines">@@ -253,11 +261,11 @@
</span><span class="cx">         // Insert the default group and fields
</span><span class="cx">         $insert_sql = array();
</span><span class="cx"> 
</span><del>-        if ( !$wpdb-&gt;get_var( &quot;SELECT id FROM {$wpdb-&gt;base_prefix}bp_xprofile_groups WHERE id = 1&quot; ) )
-                $insert_sql[] = &quot;INSERT INTO {$wpdb-&gt;base_prefix}bp_xprofile_groups ( name, description, can_delete ) VALUES ( &quot; . $wpdb-&gt;prepare( '%s', stripslashes( get_site_option( 'bp-xprofile-base-group-name' ) ) ) . &quot;, '', 0 );&quot;;
</del><ins>+        if ( !$wpdb-&gt;get_var( &quot;SELECT id FROM {$bp_prefix}bp_xprofile_groups WHERE id = 1&quot; ) )
+                $insert_sql[] = &quot;INSERT INTO {$bp_prefix}bp_xprofile_groups ( name, description, can_delete ) VALUES ( &quot; . $wpdb-&gt;prepare( '%s', stripslashes( get_site_option( 'bp-xprofile-base-group-name' ) ) ) . &quot;, '', 0 );&quot;;
</ins><span class="cx"> 
</span><del>-        if ( !$wpdb-&gt;get_var( &quot;SELECT id FROM {$wpdb-&gt;base_prefix}bp_xprofile_fields WHERE id = 1&quot; ) )
-                $insert_sql[] = &quot;INSERT INTO {$wpdb-&gt;base_prefix}bp_xprofile_fields ( group_id, parent_id, type, name, description, is_required, can_delete ) VALUES ( 1, 0, 'textbox', &quot; . $wpdb-&gt;prepare( '%s', stripslashes( get_site_option( 'bp-xprofile-fullname-field-name' ) ) ) . &quot;, '', 1, 0 );&quot;;
</del><ins>+        if ( !$wpdb-&gt;get_var( &quot;SELECT id FROM {$bp_prefix}bp_xprofile_fields WHERE id = 1&quot; ) )
+                $insert_sql[] = &quot;INSERT INTO {$bp_prefix}bp_xprofile_fields ( group_id, parent_id, type, name, description, is_required, can_delete ) VALUES ( 1, 0, 'textbox', &quot; . $wpdb-&gt;prepare( '%s', stripslashes( get_site_option( 'bp-xprofile-fullname-field-name' ) ) ) . &quot;, '', 1, 0 );&quot;;
</ins><span class="cx"> 
</span><span class="cx">         dbDelta( $insert_sql );
</span><span class="cx"> }
</span><span class="lines">@@ -266,8 +274,9 @@
</span><span class="cx">         global $wpdb;
</span><span class="cx"> 
</span><span class="cx">         $charset_collate = bp_core_set_charset();
</span><ins>+        $bp_prefix = bp_core_get_table_prefix();
</ins><span class="cx"> 
</span><del>-        $sql[] = &quot;CREATE TABLE {$wpdb-&gt;base_prefix}bp_user_blogs (
</del><ins>+        $sql[] = &quot;CREATE TABLE {$bp_prefix}bp_user_blogs (
</ins><span class="cx">                               id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
</span><span class="cx">                             user_id bigint(20) NOT NULL,
</span><span class="cx">                             blog_id bigint(20) NOT NULL,
</span><span class="lines">@@ -275,7 +284,7 @@
</span><span class="cx">                             KEY blog_id (blog_id)
</span><span class="cx">                        ) {$charset_collate};&quot;;
</span><span class="cx"> 
</span><del>-        $sql[] = &quot;CREATE TABLE {$wpdb-&gt;base_prefix}bp_user_blogs_blogmeta (
</del><ins>+        $sql[] = &quot;CREATE TABLE {$bp_prefix}bp_user_blogs_blogmeta (
</ins><span class="cx">                                 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
</span><span class="cx">                                 blog_id bigint(20) NOT NULL,
</span><span class="cx">                                 meta_key varchar(255) DEFAULT NULL,
</span></span></pre></div>
<a id="trunkbpcoreadminbpcoreupdatephp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/admin/bp-core-update.php (4390 => 4391)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/admin/bp-core-update.php        2011-05-19 16:08:09 UTC (rev 4390)
+++ trunk/bp-core/admin/bp-core-update.php        2011-05-19 17:01:39 UTC (rev 4391)
</span><span class="lines">@@ -1098,9 +1098,10 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function bp_update_db_stuff() {
</span><ins>+        $bp_prefix = bp_core_get_table_prefix();
</ins><span class="cx">         // Rename the old user activity cached table if needed.
</span><del>-        if ( $wpdb-&gt;get_var( &quot;SHOW TABLES LIKE '%{$wpdb-&gt;base_prefix}bp_activity_user_activity_cached%'&quot; ) )
-                $wpdb-&gt;query( &quot;RENAME TABLE {$wpdb-&gt;base_prefix}bp_activity_user_activity_cached TO {$bp-&gt;activity-&gt;table_name}&quot; );
</del><ins>+        if ( $wpdb-&gt;get_var( &quot;SHOW TABLES LIKE '%{$bp_prefix}bp_activity_user_activity_cached%'&quot; ) )
+                $wpdb-&gt;query( &quot;RENAME TABLE {$bp_prefix}bp_activity_user_activity_cached TO {$bp-&gt;activity-&gt;table_name}&quot; );
</ins><span class="cx"> 
</span><span class="cx">         // Rename fields from pre BP 1.2
</span><span class="cx">         if ( $wpdb-&gt;get_var( &quot;SHOW TABLES LIKE '%{$bp-&gt;activity-&gt;table_name}%'&quot; ) ) {
</span><span class="lines">@@ -1121,11 +1122,11 @@
</span><span class="cx">                 bp_core_add_illegal_names();
</span><span class="cx"> 
</span><span class="cx">         // Update and remove the message threads table if it exists
</span><del>-        if ( $wpdb-&gt;get_var( &quot;SHOW TABLES LIKE '%{$wpdb-&gt;base_prefix}bp_messages_threads%'&quot; ) ) {
</del><ins>+        if ( $wpdb-&gt;get_var( &quot;SHOW TABLES LIKE '%{$bp_prefix}bp_messages_threads%'&quot; ) ) {
</ins><span class="cx">                 $update = BP_Messages_Thread::update_tables();
</span><span class="cx"> 
</span><span class="cx">                 if ( $update )
</span><del>-                        $wpdb-&gt;query( &quot;DROP TABLE {$wpdb-&gt;base_prefix}bp_messages_threads&quot; );
</del><ins>+                        $wpdb-&gt;query( &quot;DROP TABLE {$bp_prefix}bp_messages_threads&quot; );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>