<!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][3736] trunk: Modifies upgrade routine so that a site's front-end can continue to be accessible after a BP upgrade but before the wizard has been completed.</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>3736</dd>
<dt>Author</dt> <dd>boonebgorges</dd>
<dt>Date</dt> <dd>2011-01-18 22:46:09 +0000 (Tue, 18 Jan 2011)</dd>
</dl>

<h3>Log Message</h3>
<pre>Modifies upgrade routine so that a site's front-end can continue to be accessible after a BP upgrade but before the wizard has been completed. Adds upgrade nags to the Dashboard. Fixes #2789. Props r-a-y and DJPaul for earlier patches and help testing</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpblogsphp">trunk/bp-blogs.php</a></li>
<li><a href="#trunkbpcoreadminbpcoreupdatephp">trunk/bp-core/admin/bp-core-update.php</a></li>
<li><a href="#trunkbpcorephp">trunk/bp-core.php</a></li>
<li><a href="#trunkbploaderphp">trunk/bp-loader.php</a></li>
<li><a href="#trunkbpthemesbpdefaultfunctionsphp">trunk/bp-themes/bp-default/functions.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpblogsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-blogs.php (3735 => 3736)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-blogs.php        2011-01-18 21:30:23 UTC (rev 3735)
+++ trunk/bp-blogs.php        2011-01-18 22:46:09 UTC (rev 3736)
</span><span class="lines">@@ -13,16 +13,16 @@
</span><span class="cx"> 
</span><span class="cx">         if ( !defined( 'BP_BLOGS_SLUG' ) &amp;&amp; isset( $bp-&gt;pages-&gt;blogs-&gt;slug ) )
</span><span class="cx">                 define ( 'BP_BLOGS_SLUG', bp_core_component_slug_from_root_slug( $bp-&gt;pages-&gt;blogs-&gt;slug ) );
</span><del>-        else if( !defined( 'BP_BLOGS_SLUG' ) )
</del><ins>+        else if ( !defined( 'BP_BLOGS_SLUG' ) )
</ins><span class="cx">                 define ( 'BP_BLOGS_SLUG', 'blogs' );
</span><span class="cx"> 
</span><span class="cx">         // For internal identification
</span><span class="cx">         $bp-&gt;blogs-&gt;id   = 'blogs';
</span><del>-        $bp-&gt;blogs-&gt;name = $bp-&gt;pages-&gt;blogs-&gt;name;
</del><ins>+        $bp-&gt;blogs-&gt;name = !empty( $bp-&gt;pages-&gt;blogs-&gt;name ) ? $bp-&gt;pages-&gt;blogs-&gt;name : 'blogs';
</ins><span class="cx"> 
</span><span class="cx">         // Slugs
</span><span class="cx">         $bp-&gt;blogs-&gt;slug      = BP_BLOGS_SLUG;
</span><del>-        $bp-&gt;blogs-&gt;root_slug = $bp-&gt;pages-&gt;blogs-&gt;slug;
</del><ins>+        $bp-&gt;blogs-&gt;root_slug = !empty( $bp-&gt;pages-&gt;blogs-&gt;slug ) ? $bp-&gt;pages-&gt;blogs-&gt;slug : BP_BLOGS_SLUG;
</ins><span class="cx"> 
</span><span class="cx">         // Tables
</span><span class="cx">         $bp-&gt;blogs-&gt;table_name          = $bp-&gt;table_prefix . 'bp_user_blogs';
</span><span class="lines">@@ -557,6 +557,9 @@
</span><span class="cx"> 
</span><span class="cx"> function bp_blogs_remove_post( $post_id, $blog_id = false, $user_id = false ) {
</span><span class="cx">         global $current_blog, $bp;
</span><ins>+        
+        if ( empty( $current_blog-&gt;blog_id ) )
+                return false;
</ins><span class="cx"> 
</span><span class="cx">         $post_id = (int)$post_id;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkbpcoreadminbpcoreupdatephp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/admin/bp-core-update.php (3735 => 3736)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/admin/bp-core-update.php        2011-01-18 21:30:23 UTC (rev 3735)
+++ trunk/bp-core/admin/bp-core-update.php        2011-01-18 22:46:09 UTC (rev 3736)
</span><span class="lines">@@ -1,45 +1,5 @@
</span><span class="cx"> &lt;?php
</span><span class="cx"> 
</span><del>-if ( !defined( 'BP_ROOT_BLOG' ) )
-        define( 'BP_ROOT_BLOG', 1 );
-
-require_once( dirname( dirname( __FILE__ ) ) . '/bp-core-wpabstraction.php' );
-
-register_theme_directory( WP_PLUGIN_DIR . '/buddypress/bp-themes' );
-
-// Install site options on activation
-bp_core_activate_site_options( array( 'bp-disable-account-deletion' =&gt; 0, 'bp-disable-avatar-uploads' =&gt; 0, 'bp-disable-blogforum-comments' =&gt; 0,  'bp-disable-forum-directory' =&gt; 0,  'bp-disable-profile-sync' =&gt; 0 ) );
-
-/**
- * When switching from single to multisite we need to copy blog options to
- * site options.
- *
- * @package BuddyPress Core
- */
-function bp_core_activate_site_options( $keys = array() ) {
-        global $bp;
-
-        $bp-&gt;site_options = bp_core_get_site_options();
-
-        if ( !empty( $keys ) &amp;&amp; is_array( $keys ) ) {
-                $errors = false;
-
-                foreach ( $keys as $key =&gt; $default ) {
-                        if ( empty( $bp-&gt;site_options[ $key ] ) ) {
-                                $bp-&gt;site_options[ $key ] = get_blog_option( BP_ROOT_BLOG, $key, $default );
-
-                                if ( !update_site_option( $key, $bp-&gt;site_options[ $key ] ) )
-                                        $errors = true;
-                        }
-                }
-
-                if ( empty( $errors ) )
-                        return true;
-        }
-
-        return false;
-}
-
</del><span class="cx"> class BP_Core_Setup_Wizard {
</span><span class="cx">         var $current_step;
</span><span class="cx">         var $steps;
</span><span class="lines">@@ -114,7 +74,7 @@
</span><span class="cx">                         if ( $this-&gt;current_version &lt; $this-&gt;new_version )
</span><span class="cx">                                 $steps[] = __( 'Database Update', 'buddypress' );
</span><span class="cx"> 
</span><del>-                        if ( $this-&gt;current_version &lt; 1225 )
</del><ins>+                        if ( $this-&gt;current_version &lt; 1225 || ( function_exists( 'bp_core_get_page_meta' ) &amp;&amp; !bp_core_get_page_meta() ) )
</ins><span class="cx">                                 $steps[] = __( 'Pages', 'buddypress' );
</span><span class="cx"> 
</span><span class="cx">                         $steps[] = __( 'Finish', 'buddypress' );
</span><span class="lines">@@ -151,7 +111,7 @@
</span><span class="cx">                                 $result = $this-&gt;step_finish_save();
</span><span class="cx">                                 break;
</span><span class="cx">                 }
</span><del>-
</del><ins>+                
</ins><span class="cx">                 if ( !$result &amp;&amp; $this-&gt;current_step )
</span><span class="cx">                         $this-&gt;current_step--;
</span><span class="cx"> 
</span><span class="lines">@@ -460,37 +420,37 @@
</span><span class="cx">                 $disabled_components = apply_filters( 'bp_deactivated_components', get_site_option( 'bp-deactivated-components' ) );
</span><span class="cx"> 
</span><span class="cx">                 // Check for defined slugs
</span><del>-                if ( defined( 'BP_MEMBERS_SLUG' ) )
</del><ins>+                if ( defined( 'BP_MEMBERS_SLUG' ) &amp;&amp; BP_MEMBERS_SLUG )
</ins><span class="cx">                         $members_slug = constant( 'BP_MEMBERS_SLUG' );
</span><span class="cx">                 else
</span><span class="cx">                         $members_slug = __( 'members', 'buddypress' );
</span><span class="cx"> 
</span><del>-                if ( defined( 'BP_GROUPS_SLUG' ) )
</del><ins>+                if ( defined( 'BP_GROUPS_SLUG' ) &amp;&amp; BP_GROUPS_SLUG )
</ins><span class="cx">                         $groups_slug = constant( 'BP_GROUPS_SLUG' );
</span><span class="cx">                 else
</span><span class="cx">                         $groups_slug = __( 'groups', 'buddypress' );
</span><span class="cx"> 
</span><del>-                if ( defined( 'BP_ACTIVITY_SLUG' ) )
</del><ins>+                if ( defined( 'BP_ACTIVITY_SLUG' ) &amp;&amp; BP_ACTIVITY_SLUG )
</ins><span class="cx">                         $activity_slug = constant( 'BP_ACTIVITY_SLUG' );
</span><span class="cx">                 else
</span><span class="cx">                         $activity_slug = __( 'activity', 'buddypress' );
</span><span class="cx"> 
</span><del>-                if ( defined( 'BP_FORUMS_SLUG' ) )
</del><ins>+                if ( defined( 'BP_FORUMS_SLUG' ) &amp;&amp; BP_FORUMS_SLUG )
</ins><span class="cx">                         $forums_slug = constant( 'BP_FORUMS_SLUG' );
</span><span class="cx">                 else
</span><span class="cx">                         $forums_slug = __( 'forums', 'buddypress' );
</span><span class="cx"> 
</span><del>-                if ( defined( 'BP_BLOGS_SLUG' ) )
</del><ins>+                if ( defined( 'BP_BLOGS_SLUG' ) &amp;&amp; BP_BLOGS_SLUG )
</ins><span class="cx">                         $blogs_slug = constant( 'BP_BLOGS_SLUG' );
</span><span class="cx">                 else
</span><span class="cx">                         $blogs_slug = __( 'blogs', 'buddypress' );
</span><span class="cx"> 
</span><del>-                if ( defined( 'BP_REGISTER_SLUG' ) )
</del><ins>+                if ( defined( 'BP_REGISTER_SLUG' ) &amp;&amp; BP_REGISTER_SLUG )
</ins><span class="cx">                         $register_slug = constant( 'BP_REGISTER_SLUG' );
</span><span class="cx">                 else
</span><span class="cx">                         $register_slug = __( 'register', 'buddypress' );
</span><span class="cx"> 
</span><del>-                if ( defined( 'BP_ACTIVATION_SLUG' ) )
</del><ins>+                if ( defined( 'BP_ACTIVATION_SLUG' ) &amp;&amp; BP_ACTIVATION_SLUG )
</ins><span class="cx">                         $activation_slug = constant( 'BP_ACTIVATION_SLUG' );
</span><span class="cx">                 else
</span><span class="cx">                         $activation_slug = __( 'activate', 'buddypress' );
</span><span class="lines">@@ -786,7 +746,11 @@
</span><span class="cx">         &lt;?php
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        function step_finish() {
</del><ins>+        function step_finish() {                        
+                // Update the DB version in the database
+                update_site_option( 'bp-db-version', constant( 'BP_DB_VERSION' ) );
+                delete_site_option( 'bp-core-db-version' );
+        
</ins><span class="cx">                 if ( !current_user_can( 'activate_plugins' ) )
</span><span class="cx">                         return false;
</span><span class="cx"> 
</span><span class="lines">@@ -828,7 +792,7 @@
</span><span class="cx"> 
</span><span class="cx">                         if ( $this-&gt;current_version &lt; 1225 )
</span><span class="cx">                                 $this-&gt;update_1_3();
</span><del>-
</del><ins>+                                
</ins><span class="cx">                         return true;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="lines">@@ -917,7 +881,7 @@
</span><span class="cx">                                 switch_to_blog( BP_ROOT_BLOG );
</span><span class="cx"> 
</span><span class="cx">                         // Delete any existing pages
</span><del>-                        $existing_pages = get_option( 'bp-pages' );
</del><ins>+                        $existing_pages = bp_core_update_get_page_meta( 'bp-pages' );
</ins><span class="cx"> 
</span><span class="cx">                         foreach ( (array)$existing_pages as $page_id )
</span><span class="cx">                                 wp_delete_post( $page_id, true );
</span><span class="lines">@@ -1060,7 +1024,7 @@
</span><span class="cx">         function step_finish_save() {
</span><span class="cx">                 if ( isset( $_POST['submit'] ) ) {
</span><span class="cx">                         check_admin_referer( 'bpwizard_finish' );
</span><del>-
</del><ins>+                        
</ins><span class="cx">                         // Delete the setup cookie
</span><span class="cx">                         @setcookie( 'bp-wizard-step', '', time() - 3600, COOKIEPATH );
</span><span class="cx"> 
</span><span class="lines">@@ -1121,7 +1085,6 @@
</span><span class="cx"> }
</span><span class="cx"> add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu', 'bp_core_setup_wizard_init', 7 );
</span><span class="cx"> 
</span><del>-
</del><span class="cx"> function bp_core_install( $disabled = false ) {
</span><span class="cx">         global $wpdb;
</span><span class="cx"> 
</span><span class="lines">@@ -1198,13 +1161,11 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * bp_core_add_admin_menu_page()
- *
</del><span class="cx">  * A better version of add_admin_menu_page() that allows positioning of menus.
</span><span class="cx">  *
</span><span class="cx">  * @package BuddyPress Core
</span><span class="cx">  */
</span><del>-function bp_core_add_admin_menu_page( $args = '' ) {
</del><ins>+function bp_core_update_add_admin_menu_page( $args = '' ) {
</ins><span class="cx">         global $menu, $admin_page_hooks, $_registered_pages;
</span><span class="cx"> 
</span><span class="cx">         $defaults = array(
</span><span class="lines">@@ -1271,9 +1232,13 @@
</span><span class="cx">  * @global $wpdb WordPress DB access object.
</span><span class="cx">  * @uses add_submenu_page() WP function to add a submenu item
</span><span class="cx">  */
</span><del>-function bp_core_add_admin_menu() {
</del><ins>+function bp_core_update_add_admin_menu() {
</ins><span class="cx">         global $bp_wizard;
</span><span class="cx"> 
</span><ins>+        // Only load this version of the menu if this is an upgrade or a new installation 
+        if ( ( !defined( 'BP_IS_UPGRADE' ) || !BP_IS_UPGRADE ) &amp;&amp; ( !defined( 'BP_IS_INSTALL' ) || !BP_IS_INSTALL ) ) 
+                return false; 
+        
</ins><span class="cx">         if ( !current_user_can( 'activate_plugins' ) )
</span><span class="cx">                 return false;
</span><span class="cx"> 
</span><span class="lines">@@ -1283,7 +1248,7 @@
</span><span class="cx">                 $status = __( 'Update', 'buddypress' );
</span><span class="cx"> 
</span><span class="cx">         // Add the administration tab under the &quot;Site Admin&quot; tab for site administrators
</span><del>-        bp_core_add_admin_menu_page( array(
</del><ins>+        bp_core_update_add_admin_menu_page( array(
</ins><span class="cx">                 'menu_title'   =&gt; __( 'BuddyPress', 'buddypress' ),
</span><span class="cx">                 'page_title'   =&gt; __( 'BuddyPress', 'buddypress' ),
</span><span class="cx">                 'capability'   =&gt; 'manage_options',
</span><span class="lines">@@ -1295,11 +1260,11 @@
</span><span class="cx">         $hook = add_submenu_page( 'bp-wizard', $status, $status, 'manage_options', 'bp-wizard', array( $bp_wizard, 'html' ) );
</span><span class="cx"> 
</span><span class="cx">         // Add a hook for css/js
</span><del>-        add_action( &quot;admin_print_styles-$hook&quot;, 'bp_core_add_admin_menu_styles' );
</del><ins>+        add_action( &quot;admin_print_styles-$hook&quot;, 'bp_core_update_add_admin_menu_styles' );
</ins><span class="cx"> }
</span><del>-add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu',  'bp_core_add_admin_menu', 9 );
</del><ins>+add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu',  'bp_core_update_add_admin_menu', 9 );
</ins><span class="cx"> 
</span><del>-function bp_core_add_admin_menu_styles() {
</del><ins>+function bp_core_update_add_admin_menu_styles() {
</ins><span class="cx">         if ( defined( 'SCRIPT_DEBUG' ) &amp;&amp; SCRIPT_DEBUG )
</span><span class="cx">                 wp_enqueue_style( 'bp-admin-css', apply_filters( 'bp_core_admin_css', plugins_url( $path = '/buddypress' ) . '/bp-core/css/admin.dev.css' ) );
</span><span class="cx">         else
</span><span class="lines">@@ -1328,6 +1293,49 @@
</span><span class="cx"> 
</span><span class="cx"> &lt;?php
</span><span class="cx"> }
</span><del>-add_action( 'admin_head', 'bp_core_add_admin_menu_styles' );
</del><ins>+add_action( 'admin_head', 'bp_core_update_add_admin_menu_styles' );
</ins><span class="cx"> 
</span><ins>+/**
+ * Fetches BP pages from the meta table, depending on setup
+ *
+ * @package BuddyPress Core
+ * @since 1.3
+ *
+ * @return array $page_ids
+ */
+function bp_core_update_get_page_meta() {
+        if ( !defined( 'BP_ENABLE_MULTIBLOG' ) &amp;&amp; is_multisite() )
+                $page_ids = get_blog_option( BP_ROOT_BLOG, 'bp-pages' );
+        else
+                $page_ids = get_option( 'bp-pages' );
+
+        return $page_ids;
+}
+
+/** 
+ * Adds an admin nag about running the BP upgrade/install wizard 
+ * 
+ * @package BuddyPress Core 
+ * @since 1.3 
+ * @global $pagenow The current admin page 
+ */ 
+function bp_core_update_nag() { 
+        global $pagenow; 
+
+          if ( !is_super_admin() ) 
+                  return; 
+          
+          if ( 'admin.php' == $pagenow &amp;&amp; ( empty( $_GET['page'] ) || 'bp-wizard' == $_GET['page'] ) ) 
+                  return; 
+          
+          if ( defined( 'BP_IS_UPGRADE' ) &amp;&amp; BP_IS_UPGRADE ) 
+                  $msg = sprintf( __( 'BuddyPress has been updated! Please run the &lt;a href=&quot;%s&quot;&gt;upgrade wizard&lt;/a&gt;.', 'buddypress' ), admin_url( 'admin.php?page=bp-wizard' ) ); 
+          else if ( defined( 'BP_IS_INSTALL' ) &amp;&amp; BP_IS_INSTALL ) 
+                  $msg = sprintf( __( 'BuddyPress has been installed! Please run the &lt;a href=&quot;%s&quot;&gt;upgrade wizard&lt;/a&gt;.', 'buddypress' ), admin_url( 'admin.php?page=bp-wizard' ) ); 
+                  
+          echo &quot;&lt;div class='update-nag'&gt;$msg&lt;/div&gt;&quot;; 
+} 
+add_action( 'admin_notices', 'bp_core_update_nag', 5 ); 
+
+
</ins><span class="cx"> ?&gt;
</span></span></pre></div>
<a id="trunkbpcorephp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core.php (3735 => 3736)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core.php        2011-01-18 21:30:23 UTC (rev 3735)
+++ trunk/bp-core.php        2011-01-18 22:46:09 UTC (rev 3736)
</span><span class="lines">@@ -43,9 +43,6 @@
</span><span class="cx"> if ( !defined( 'BP_DISABLE_ADMIN_BAR' ) )
</span><span class="cx">         require ( BP_PLUGIN_DIR . '/bp-core/bp-core-adminbar.php' );
</span><span class="cx"> 
</span><del>-// Register BuddyPress themes contained within the bp-theme folder
-register_theme_directory( WP_PLUGIN_DIR . '/buddypress/bp-themes' );
-
</del><span class="cx"> /** &quot;And now for something completely different&quot; ******************************/
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="lines">@@ -207,6 +204,9 @@
</span><span class="cx">  * Define the slugs used for BuddyPress pages, based on the slugs of the WP pages used.
</span><span class="cx">  * These can be overridden manually by defining these slugs in wp-config.php.
</span><span class="cx">  *
</span><ins>+ * The fallback values are only used during initial BP page creation, when no slugs have been
+ * explicitly defined.
+ *
</ins><span class="cx">  * @package BuddyPress Core Core
</span><span class="cx">  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
</span><span class="cx">  */
</span><span class="lines">@@ -215,12 +215,13 @@
</span><span class="cx"> 
</span><span class="cx">         if ( !defined( 'BP_MEMBERS_SLUG' ) )
</span><span class="cx">                 define( 'BP_MEMBERS_SLUG', $bp-&gt;pages-&gt;members-&gt;slug );
</span><del>-
</del><ins>+        
</ins><span class="cx">         if ( !defined( 'BP_REGISTER_SLUG' ) )
</span><span class="cx">                 define( 'BP_REGISTER_SLUG', $bp-&gt;pages-&gt;register-&gt;slug );
</span><del>-
</del><ins>+        
</ins><span class="cx">         if ( !defined( 'BP_ACTIVATION_SLUG' ) )
</span><span class="cx">                 define( 'BP_ACTIVATION_SLUG', $bp-&gt;pages-&gt;activate-&gt;slug );
</span><ins>+        
</ins><span class="cx"> }
</span><span class="cx"> add_action( 'bp_setup_globals', 'bp_core_define_slugs' );
</span><span class="cx"> 
</span><span class="lines">@@ -257,15 +258,35 @@
</span><span class="cx"> 
</span><span class="cx">         $page_ids = bp_core_get_page_meta();
</span><span class="cx"> 
</span><del>-        if ( empty( $page_ids ) )
-                return false;
</del><ins>+        $pages = new stdClass;
</ins><span class="cx"> 
</span><ins>+        // When upgrading to BP 1.3+ from a version of BP that does not use WP pages, $bp-&gt;pages
+        // must be populated with dummy info to avoid crashing the site while the db is upgraded
+        if ( empty( $page_ids ) ) {
+                $dummy_components = array(
+                        'members',
+                        'groups',
+                        'activity',
+                        'forums',
+                        'activate',
+                        'register',
+                        'blogs'
+                );
+                
+                foreach ( $dummy_components as $dc ) {
+                        $pages-&gt;{$dc}-&gt;name         = $dc;
+                        $pages-&gt;{$dc}-&gt;slug         = $dc;
+                        $pages-&gt;{$dc}-&gt;id         = $dc;
+                }
+                
+                return $pages;
+        }
+
</ins><span class="cx">         $posts_table_name = is_multisite() &amp;&amp; !defined( 'BP_ENABLE_MULTIBLOG' ) ? $wpdb-&gt;get_blog_prefix( BP_ROOT_BLOG ) . 'posts' : $wpdb-&gt;posts;
</span><span class="cx"> 
</span><span class="cx">         $page_ids_sql = implode( ',', (array)$page_ids );
</span><span class="cx"> 
</span><span class="cx">         $page_names = $wpdb-&gt;get_results( $wpdb-&gt;prepare( &quot;SELECT ID, post_name, post_parent FROM {$posts_table_name} WHERE ID IN ({$page_ids_sql}) &quot; ) );
</span><del>-        $pages = new stdClass;
</del><span class="cx"> 
</span><span class="cx">         foreach ( (array)$page_ids as $key =&gt; $page_id ) {
</span><span class="cx">                 foreach ( (array)$page_names as $page_name ) {
</span><span class="lines">@@ -347,6 +368,11 @@
</span><span class="cx"> function bp_core_add_admin_menu() {
</span><span class="cx">         if ( !is_super_admin() )
</span><span class="cx">                 return false;
</span><ins>+        
+        // Don't add this version of the admin menu if a BP upgrade is in progress 
+         // See bp_core_update_add_admin_menu() 
+        if ( defined( 'BP_IS_UPGRADE' ) &amp;&amp; BP_IS_UPGRADE ) 
+                 return false; 
</ins><span class="cx"> 
</span><span class="cx">         // Add the administration tab under the &quot;Site Admin&quot; tab for site administrators
</span><span class="cx">         $hook = bp_core_add_admin_menu_page( array(
</span></span></pre></div>
<a id="trunkbploaderphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-loader.php (3735 => 3736)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-loader.php        2011-01-18 21:30:23 UTC (rev 3735)
+++ trunk/bp-loader.php        2011-01-18 22:46:09 UTC (rev 3736)
</span><span class="lines">@@ -10,23 +10,24 @@
</span><span class="cx"> */
</span><span class="cx"> 
</span><span class="cx"> define( 'BP_VERSION', '1.3-bleeding' );
</span><del>-define( 'BP_DB_VERSION', 1225 );
</del><ins>+define( 'BP_DB_VERSION', 3705 );
</ins><span class="cx"> 
</span><span class="cx"> // Define on which blog ID BuddyPress should run
</span><span class="cx"> if ( !defined( 'BP_ROOT_BLOG' ) )
</span><span class="cx">         define( 'BP_ROOT_BLOG', 1 );
</span><span class="cx"> 
</span><del>-/***
- * Check if this is the first time BuddyPress has been loaded, or the first time
- * since an update. If so, load the install/update routine only.
- */
-if ( get_site_option( 'bp-db-version' ) &lt; constant( 'BP_DB_VERSION' ) ) {
</del><ins>+// Register BuddyPress themes contained within the bp-themes folder 
+register_theme_directory( WP_PLUGIN_DIR . '/buddypress/bp-themes' ); 
+         
+// Test to see whether this is a new installation or an upgraded version of BuddyPress 
+$bp_db_version = get_site_option( 'bp-db-version' ); 
+if ( ! $bp_db_version ) 
+        $bp_db_version = get_site_option( 'bp-core-db-version' );  // BP 1.2 option name 
+         
+if ( ! $bp_db_version ) {
+         // This is a new installation. Run the wizard before loading BP core files
+         define( 'BP_IS_INSTALL', true ); 
</ins><span class="cx">         require_once( WP_PLUGIN_DIR . '/buddypress/bp-core/admin/bp-core-update.php' );
</span><del>-
-/***
- * If the install or update routine is completed and everything is up to date
- * continue loading BuddyPress as normal.
- */
</del><span class="cx"> } else {
</span><span class="cx">         /***
</span><span class="cx">          * This file will load in each BuddyPress component based on which
</span><span class="lines">@@ -64,6 +65,12 @@
</span><span class="cx">         // Extended Profiles
</span><span class="cx">         if ( !isset( $bp_deactivated['bp-xprofile.php'] ) &amp;&amp; file_exists( BP_PLUGIN_DIR . '/bp-xprofile.php') )
</span><span class="cx">                 include( BP_PLUGIN_DIR . '/bp-xprofile.php' );
</span><ins>+                
+        // If this is an upgrade, load the upgrade file 
+         if ( $bp_db_version &lt; constant( 'BP_DB_VERSION' ) ) { 
+                 define( 'BP_IS_UPGRADE', true ); 
+                 require_once( WP_PLUGIN_DIR . '/buddypress/bp-core/admin/bp-core-update.php' ); 
+         } 
</ins><span class="cx"> 
</span><span class="cx">         add_action( 'plugins_loaded', 'bp_loaded', 20 );
</span><span class="cx"> }
</span><span class="lines">@@ -135,11 +142,22 @@
</span><span class="cx">         return apply_filters( 'bp_core_get_site_options', $site_options );
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-// Activation Function
</del><ins>+/** 
+ * Defines BP's activation routine. 
+ * 
+ * Most of BP's crucial setup is handled by the setup wizard. This function takes care of some 
+ * issues with incompatible legacy themes, and provides a hook for other functions to know that 
+ * BP has been activated. 
+ * 
+ * @package BuddyPress Core 
+*/ 
</ins><span class="cx"> function bp_loader_activate() {
</span><span class="cx">         // Force refresh theme roots.
</span><span class="cx">         delete_site_transient( 'theme_roots' );
</span><span class="cx"> 
</span><ins>+        if ( !function_exists( 'get_blog_option' ) )
+                require ( WP_PLUGIN_DIR . '/buddypress/bp-core/bp-core-wpabstraction.php' );
+
</ins><span class="cx">         // Switch the user to the new bp-default if they are using the old
</span><span class="cx">         // bp-default on activation.
</span><span class="cx">         if ( 'bp-sn-parent' == get_blog_option( BP_ROOT_BLOG, 'template' ) &amp;&amp; 'bp-default' == get_blog_option( BP_ROOT_BLOG, 'stylesheet' ) )
</span></span></pre></div>
<a id="trunkbpthemesbpdefaultfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-default/functions.php (3735 => 3736)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-default/functions.php        2011-01-18 21:30:23 UTC (rev 3735)
+++ trunk/bp-themes/bp-default/functions.php        2011-01-18 22:46:09 UTC (rev 3736)
</span><span class="lines">@@ -36,16 +36,6 @@
</span><span class="cx"> if ( ! isset( $content_width ) )
</span><span class="cx">         $content_width = 591;
</span><span class="cx"> 
</span><del>-/**
- * Temporary work-around to prevent errors with bp-default being active
- * when BuddyPress is not installed.
- */
-if ( !constant( 'BP_VERSION' ) || !get_site_option( 'bp-db-version' ) ) {
-        switch_theme( 'twentyten', 'twentyten' );
-        wp_redirect( $_SERVER['HTTP_REFERER'] );
-        exit;
-}
-
</del><span class="cx"> if ( !function_exists( 'bp_dtheme_setup' ) ) :
</span><span class="cx"> /**
</span><span class="cx">  * Sets up theme defaults and registers support for various WordPress and BuddyPress features.
</span></span></pre>
</div>
</div>

</body>
</html>