Changeset 8309 for branches/2.0/bp-core/bp-core-update.php
- Timestamp:
- 04/21/2014 09:48:38 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.0/bp-core/bp-core-update.php
r8301 r8309 350 350 */ 351 351 function bp_update_to_2_0() { 352 global $wpdb;353 352 354 353 /** Install activity tables for 'last_activity' ***************************/ … … 462 461 } 463 462 464 // Check for the table (we suppress errors because users shouldn't see this)463 // Suppress errors because users shouldn't see this 465 464 $old_suppress = $wpdb->suppress_errors(); 466 465 467 466 // Never use bp_core_get_table_prefix() for any global users tables 467 // We also don't use $wpdb->signups because we want decisive evidence. 468 468 $table_exists = $wpdb->get_results( "DESCRIBE {$wpdb->base_prefix}signups;" ); 469 469 … … 473 473 // Return whether or not the table exists 474 474 return (bool) $table_exists; 475 } 476 477 /** 478 * Check if the signups table already exists 479 * 480 * @since BuddyPress (2.0.1) 481 * 482 * @global WPDB $wpdb 483 * 484 * @link https://core.trac.wordpress.org/changeset/25179 485 * 486 * @return bool If signup_id column exists 487 */ 488 function bp_core_signups_id_column_exists() { 489 global $wpdb; 490 491 // No signups table to query, so bail and return false 492 if ( empty( $wpdb->signups ) ) { 493 return false; 494 } 495 496 // Suppress errors because users shouldn't see this 497 $old_suppress = $wpdb->suppress_errors(); 498 499 // Never use bp_core_get_table_prefix() for any global users tables 500 $column_exists = $wpdb->query( "SHOW COLUMNS FROM {$wpdb->signups} LIKE 'signup_id'" ); 501 502 // Restore previous error suppression setting 503 $wpdb->suppress_errors( $old_suppress ); 504 505 // Column does not exist 506 return $column_exists; 475 507 } 476 508 … … 491 523 } 492 524 493 // Try to install the sign-ups table 494 if ( ! is_multisite() && ! bp_core_signups_table_exists() ) { 525 // Table already exists, so maybe upgrade instead? 526 if ( bp_core_signups_table_exists() ) { 527 528 // 'signup_id' column doesn't exist, so run the upgrade 529 if ( ! bp_core_signups_id_column_exists() ) { 530 bp_core_upgrade_signups(); 531 } 532 533 // Table does not exist, and not multisite, so install the signups table 534 } elseif ( ! is_multisite() ) { 495 535 bp_core_install_signups(); 496 536 } 497 498 // Return whether or not the table exists now499 return (bool) bp_core_signups_table_exists();500 }501 502 /**503 * Check if the signups table needs to be upgraded.504 *505 * Update the signups table, adding `signup_id` column and drop `domain` index.506 *507 * This is necessary because WordPress's `pre_schema_upgrade()` function wraps508 * table ALTER's in multisite checks, and other plugins may have installed their509 * own sign-ups table; Eg: Gravity Forms User Registration Add On510 *511 * @since BuddyPress (2.0.1)512 *513 * @see pre_schema_upgrade()514 * @link https://core.trac.wordpress.org/ticket/27855 WordPress Trac Ticket515 * @link https://buddypress.trac.wordpress.org/ticket/5563 BuddyPress Trac Ticket516 *517 * @return bool If signups table exists518 */519 function bp_core_maybe_upgrade_signups() {520 521 // Bail if we are explicitly not upgrading global tables522 if ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) {523 return false;524 }525 526 // Actually upgrade the sign-ups table527 if ( bp_core_maybe_install_signups() ) {528 bp_core_upgrade_signups();529 }530 531 // Return whether or not the table exists now532 return (bool) bp_core_signups_table_exists();533 537 } 534 538
Note: See TracChangeset
for help on using the changeset viewer.