Changeset 10497 for trunk/src/bp-core/bp-core-update.php
- Timestamp:
- 02/03/2016 05:01:13 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-update.php
r10474 r10497 43 43 function bp_is_update() { 44 44 45 // Current DB version of this site (per site in a multisite network) 45 // Current DB version of this site (per site in a multisite network). 46 46 $current_db = bp_get_option( '_bp_db_version' ); 47 47 $current_live = bp_get_db_version(); 48 48 49 // Compare versions (cast as int and bool to be safe) 49 // Compare versions (cast as int and bool to be safe). 50 50 $is_update = (bool) ( (int) $current_db < (int) $current_live ); 51 51 52 // Return the product of version comparison 52 // Return the product of version comparison. 53 53 return $is_update; 54 54 } … … 74 74 } 75 75 76 // Bail if not activating 76 // Bail if not activating. 77 77 if ( empty( $action ) || !in_array( $action, array( 'activate', 'activate-selected' ) ) ) { 78 78 return false; 79 79 } 80 80 81 // The plugin(s) being activated 81 // The plugin(s) being activated. 82 82 if ( $action == 'activate' ) { 83 83 $plugins = isset( $_GET['plugin'] ) ? array( $_GET['plugin'] ) : array(); … … 86 86 } 87 87 88 // Set basename if empty 88 // Set basename if empty. 89 89 if ( empty( $basename ) && !empty( $bp->basename ) ) { 90 90 $basename = $bp->basename; 91 91 } 92 92 93 // Bail if no basename 93 // Bail if no basename. 94 94 if ( empty( $basename ) ) { 95 95 return false; … … 120 120 } 121 121 122 // Bail if not deactivating 122 // Bail if not deactivating. 123 123 if ( empty( $action ) || !in_array( $action, array( 'deactivate', 'deactivate-selected' ) ) ) { 124 124 return false; 125 125 } 126 126 127 // The plugin(s) being deactivated 127 // The plugin(s) being deactivated. 128 128 if ( 'deactivate' == $action ) { 129 129 $plugins = isset( $_GET['plugin'] ) ? array( $_GET['plugin'] ) : array(); … … 132 132 } 133 133 134 // Set basename if empty 134 // Set basename if empty. 135 135 if ( empty( $basename ) && !empty( $bp->basename ) ) { 136 136 $basename = $bp->basename; 137 137 } 138 138 139 // Bail if no basename 139 // Bail if no basename. 140 140 if ( empty( $basename ) ) { 141 141 return false; … … 187 187 function bp_version_updater() { 188 188 189 // Get the raw database version 189 // Get the raw database version. 190 190 $raw_db_version = (int) bp_get_db_version_raw(); 191 191 … … 207 207 require_once( buddypress()->plugin_dir . '/bp-core/admin/bp-core-admin-schema.php' ); 208 208 209 // Install BP schema and activate only Activity and XProfile 209 // Install BP schema and activate only Activity and XProfile. 210 210 if ( bp_is_install() ) { 211 211 212 // Apply schema and set Activity and XProfile components as active 212 // Apply schema and set Activity and XProfile components as active. 213 213 bp_core_install( $default_components ); 214 214 bp_update_option( 'bp-active-components', $default_components ); … … 216 216 bp_core_install_emails(); 217 217 218 // Upgrades 218 // Upgrades. 219 219 } else { 220 220 221 // Run the schema install to update tables 221 // Run the schema install to update tables. 222 222 bp_core_install(); 223 223 … … 269 269 } 270 270 271 /* *All done! *************************************************************/272 273 // Bump the version 271 /* All done! *************************************************************/ 272 273 // Bump the version. 274 274 bp_version_bump(); 275 275 } … … 290 290 // 2.3.0: Change index lengths to account for utf8mb4. 291 291 if ( $raw_db_version < 9695 ) { 292 // table_name => columns.292 // Map table_name => columns. 293 293 $tables = array( 294 294 $bp_prefix . 'bp_activity_meta' => array( 'meta_key' ), … … 321 321 function bp_update_to_1_5() { 322 322 323 // Delete old database version options 323 // Delete old database version options. 324 324 delete_site_option( 'bp-activity-db-version' ); 325 325 delete_site_option( 'bp-blogs-db-version' ); … … 339 339 function bp_update_to_1_6() { 340 340 341 // Delete possible site options 341 // Delete possible site options. 342 342 delete_site_option( 'bp-db-version' ); 343 343 delete_site_option( '_bp_db_version' ); … … 345 345 delete_site_option( '_bp-core-db-version' ); 346 346 347 // Delete possible blog options 347 // Delete possible blog options. 348 348 delete_blog_option( bp_get_root_blog_id(), 'bp-db-version' ); 349 349 delete_blog_option( bp_get_root_blog_id(), 'bp-core-db-version' ); … … 363 363 function bp_update_to_1_9() { 364 364 365 // Setup hardcoded keys 365 // Setup hardcoded keys. 366 366 $active_components_key = 'bp-active-components'; 367 367 $notifications_component_id = 'notifications'; 368 368 369 // Get the active components 369 // Get the active components. 370 370 $active_components = bp_get_option( $active_components_key ); 371 371 372 // Add notifications 372 // Add notifications. 373 373 if ( ! in_array( $notifications_component_id, $active_components ) ) { 374 374 $active_components[ $notifications_component_id ] = 1; 375 375 } 376 376 377 // Update the active components option 377 // Update the active components option. 378 378 bp_update_option( $active_components_key, $active_components ); 379 379 } … … 412 412 function bp_update_to_2_0() { 413 413 414 /* *Install activity tables for 'last_activity' ***************************/414 /* Install activity tables for 'last_activity' ***************************/ 415 415 416 416 bp_core_install_activity_streams(); 417 417 418 /* *Migrate 'last_activity' data ******************************************/418 /* Migrate 'last_activity' data ******************************************/ 419 419 420 420 bp_last_activity_migrate(); 421 421 422 /* *Migrate signups data **************************************************/422 /* Migrate signups data **************************************************/ 423 423 424 424 if ( ! is_multisite() ) { 425 425 426 // Maybe install the signups table 426 // Maybe install the signups table. 427 427 bp_core_maybe_install_signups(); 428 428 429 // Run the migration script 429 // Run the migration script. 430 430 bp_members_migrate_signups(); 431 431 } 432 432 433 /* *Add BP options to the options table ***********************************/433 /* Add BP options to the options table ***********************************/ 434 434 435 435 bp_add_options(); … … 461 461 function bp_update_to_2_2() { 462 462 463 // Also handled by `bp_core_install()` 463 // Also handled by `bp_core_install()`. 464 464 if ( bp_is_active( 'messages' ) ) { 465 465 bp_core_install_private_messaging(); … … 484 484 function bp_update_to_2_3() { 485 485 486 // Also handled by `bp_core_install()` 486 // Also handled by `bp_core_install()`. 487 487 if ( bp_is_active( 'notifications' ) ) { 488 488 bp_core_install_notifications(); … … 508 508 * @global $wpdb 509 509 * @uses buddypress() 510 *511 510 */ 512 511 function bp_migrate_new_member_activity_component() { … … 514 513 $bp = buddypress(); 515 514 516 // Update the component for the new_member type 515 // Update the component for the new_member type. 517 516 $wpdb->update( 518 // Activity table 517 // Activity table. 519 518 $bp->members->table_name_last_activity, 520 519 array( … … 525 524 'type' => 'new_member', 526 525 ), 527 // Data sanitization format 526 // Data sanitization format. 528 527 array( 529 528 '%s', 530 529 ), 531 // WHERE sanitization format 530 // WHERE sanitization format. 532 531 array( 533 532 '%s', … … 563 562 function bp_add_activation_redirect() { 564 563 565 // Bail if activating from network, or bulk 564 // Bail if activating from network, or bulk. 566 565 if ( isset( $_GET['activate-multi'] ) ) { 567 566 return; … … 569 568 570 569 // Record that this is a new installation, so we show the right 571 // welcome message 570 // welcome message. 572 571 if ( bp_is_install() ) { 573 572 set_transient( '_bp_is_new_install', true, 30 ); 574 573 } 575 574 576 // Add the transient to redirect 575 // Add the transient to redirect. 577 576 set_transient( '_bp_activation_redirect', true, 30 ); 578 577 } … … 586 585 * 587 586 * @global WPDB $wpdb 588 *589 * @return bool|null If signups table exists.590 587 */ 591 588 function bp_core_maybe_install_signups() { 592 589 global $wpdb; 593 590 594 // The table to run queries against 591 // The table to run queries against. 595 592 $signups_table = $wpdb->base_prefix . 'signups'; 596 593 597 // Suppress errors because users shouldn't see what happens next 594 // Suppress errors because users shouldn't see what happens next. 598 595 $old_suppress = $wpdb->suppress_errors(); 599 596 600 // Never use bp_core_get_table_prefix() for any global users tables 597 // Never use bp_core_get_table_prefix() for any global users tables. 601 598 $table_exists = (bool) $wpdb->get_results( "DESCRIBE {$signups_table};" ); 602 599 … … 604 601 if ( true === $table_exists ) { 605 602 606 // Look for the 'signup_id' column 603 // Look for the 'signup_id' column. 607 604 $column_exists = $wpdb->query( "SHOW COLUMNS FROM {$signups_table} LIKE 'signup_id'" ); 608 605 … … 618 615 } 619 616 620 // Restore previous error suppression setting 617 // Restore previous error suppression setting. 621 618 $wpdb->suppress_errors( $old_suppress ); 622 619 } … … 638 635 delete_site_transient( 'theme_roots' ); 639 636 640 // Add options 637 // Add options. 641 638 bp_add_options(); 642 639
Note: See TracChangeset
for help on using the changeset viewer.