| 451 | | * Check if the signups table already exists |
| 452 | | * |
| 453 | | * @since BuddyPress (2.0.1) |
| 454 | | * |
| 455 | | * @global WPDB $wpdb |
| 456 | | * |
| 457 | | * @return bool If signups table exists |
| 458 | | */ |
| 459 | | function bp_core_signups_table_exists() { |
| 460 | | global $wpdb; |
| 461 | | |
| 462 | | // Some installations may already have a signups table (multisite, plugins, etc...) |
| 463 | | if ( ! empty( $wpdb->signups ) ) { |
| 464 | | return true; |
| 465 | | } |
| 466 | | |
| 467 | | // Suppress errors because users shouldn't see this |
| 468 | | $old_suppress = $wpdb->suppress_errors(); |
| 469 | | |
| 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. |
| 472 | | $table_exists = $wpdb->get_results( "DESCRIBE {$wpdb->base_prefix}signups;" ); |
| 473 | | |
| 474 | | // Restore previous error suppression setting |
| 475 | | $wpdb->suppress_errors( $old_suppress ); |
| 476 | | |
| 477 | | // Return whether or not the table exists |
| 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; |
| 511 | | } |
| 512 | | |
| 513 | | /** |