Changeset 8310
- Timestamp:
- 04/21/2014 09:59:55 PM (11 years ago)
- Location:
- trunk/bp-core
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/admin/bp-core-schema.php
r8302 r8310 53 53 54 54 // Install the signups table 55 bp_core_ install_signups();55 bp_core_maybe_install_signups(); 56 56 57 57 } -
trunk/bp-core/bp-core-update.php
r8302 r8310 415 415 */ 416 416 function bp_update_to_2_0_1() { 417 bp_core_maybe_upgrade_signups(); 417 418 // We purposely call this during both the 2.0 upgrade and the 2.0.1 upgrade. 419 // Don't worry; it won't break anything, and safely handles all cases. 420 bp_core_maybe_install_signups(); 418 421 } 419 422 … … 462 465 } 463 466 464 // Check for the table (we suppress errors because users shouldn't see this)467 // Suppress errors because users shouldn't see this 465 468 $old_suppress = $wpdb->suppress_errors(); 466 469 467 470 // Never use bp_core_get_table_prefix() for any global users tables 471 // We also don't use $wpdb->signups because we want decisive evidence. 468 472 $table_exists = $wpdb->get_results( "DESCRIBE {$wpdb->base_prefix}signups;" ); 469 473 … … 473 477 // Return whether or not the table exists 474 478 return (bool) $table_exists; 479 } 480 481 /** 482 * Check if the signups table already exists 483 * 484 * @since BuddyPress (2.0.1) 485 * 486 * @global WPDB $wpdb 487 * 488 * @link https://core.trac.wordpress.org/changeset/25179 489 * 490 * @return bool If signup_id column exists 491 */ 492 function bp_core_signups_id_column_exists() { 493 global $wpdb; 494 495 // No signups table to query, so bail and return false 496 if ( empty( $wpdb->signups ) ) { 497 return false; 498 } 499 500 // Suppress errors because users shouldn't see this 501 $old_suppress = $wpdb->suppress_errors(); 502 503 // Never use bp_core_get_table_prefix() for any global users tables 504 $column_exists = $wpdb->query( "SHOW COLUMNS FROM {$wpdb->signups} LIKE 'signup_id'" ); 505 506 // Restore previous error suppression setting 507 $wpdb->suppress_errors( $old_suppress ); 508 509 // Column does not exist 510 return $column_exists; 475 511 } 476 512 … … 491 527 } 492 528 493 // Try to install the sign-ups table 494 if ( ! is_multisite() && ! bp_core_signups_table_exists() ) { 529 // Table already exists, so maybe upgrade instead? 530 if ( bp_core_signups_table_exists() ) { 531 532 // 'signup_id' column doesn't exist, so run the upgrade 533 if ( ! bp_core_signups_id_column_exists() ) { 534 bp_core_upgrade_signups(); 535 } 536 537 // Table does not exist, and not multisite, so install the signups table 538 } elseif ( ! is_multisite() ) { 495 539 bp_core_install_signups(); 496 540 } 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 541 } 534 542
Note: See TracChangeset
for help on using the changeset viewer.