Changeset 6523 for trunk/src/includes/admin/tools/upgrade.php
- Timestamp:
- 06/10/2017 11:19:08 PM (9 years ago)
- File:
-
- 1 edited
-
trunk/src/includes/admin/tools/upgrade.php (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/admin/tools/upgrade.php
r6500 r6523 29 29 <div class="wrap"> 30 30 <h1><?php esc_html_e( 'Forum Tools', 'bbpress' ); ?></h1> 31 <h2 class="nav-tab-wrapper"><?php bbp_tools_admin_tabs( __( 'Upgrade Forums', 'bbpress' ) ); ?></h2>31 <h2 class="nav-tab-wrapper"><?php bbp_tools_admin_tabs( esc_html__( 'Upgrade Forums', 'bbpress' ) ); ?></h2> 32 32 33 33 <p><?php esc_html_e( 'As bbPress improves, occasionally database upgrades are required but some forums are too large to upgrade automatically. Use the tools below to manually run upgrade routines.', 'bbpress' ); ?></p> … … 166 166 // Define variables 167 167 $bbp_db = bbp_db(); 168 $statement = __( 'Upgrading user engagements… %s', 'bbpress' );169 $result = __( 'No engagements to upgrade.','bbpress' );168 $statement = esc_html__( 'Upgrading user engagements… %s', 'bbpress' ); 169 $result = esc_html__( 'No engagements to upgrade.', 'bbpress' ); 170 170 171 171 // Delete previous engagements … … 175 175 } 176 176 177 // Post types and status 177 // Post types and statuses 178 178 $tpt = bbp_get_topic_post_type(); 179 179 $rpt = bbp_get_reply_post_type(); … … 190 190 GROUP BY postmeta.meta_value, posts.post_author)", $tpt, $rpt, $pps, $cps ); 191 191 192 $engagements = $bbp_db->query( $sql ); 192 // Run the big query 193 $prepare = $bbp_db->prepare( $sql, $tpt, $rpt, $pps, $cps ); 194 $engagements = $bbp_db->query( $prepare ); 193 195 194 196 // Bail if no closed topics found … … 217 219 // Define variables 218 220 $bbp_db = bbp_db(); 219 $statement = __( 'Upgrading BuddyPress group-forum relationships… %s', 'bbpress' );221 $statement = esc_html__( 'Upgrading BuddyPress group-forum relationships… %s', 'bbpress' ); 220 222 $g_count = 0; 221 223 $f_count = 0; … … 238 240 // Bail if forum IDs returned an error 239 241 if ( is_wp_error( $forum_ids ) || empty( $bbp_db->last_result ) ) { 240 return array( 2, sprintf( $statement, __( 'Failed!', 'bbpress' ) ) );242 return array( 2, sprintf( $statement, esc_html__( 'Failed!', 'bbpress' ) ) ); 241 243 } 242 244 … … 321 323 wp_update_post( array( 322 324 'ID' => $posts[0]->ID, 323 'post_title' => __( 'Group Forums', 'bbpress' ),324 'post_name' => __( 'group-forums', 'bbpress' ),325 'post_title' => esc_html__( 'Group Forums', 'bbpress' ), 326 'post_name' => esc_html__( 'group-forums', 'bbpress' ), 325 327 ) ); 326 328 } … … 338 340 339 341 // Complete results 340 $result = sprintf( __( 'Complete! %s groups updated; %s forums updated; %s forum statuses synced.', 'bbpress' ), bbp_number_format( $g_count ), bbp_number_format( $f_count ), bbp_number_format( $s_count ) );342 $result = sprintf( esc_html__( 'Complete! %s groups updated; %s forums updated; %s forum statuses synced.', 'bbpress' ), bbp_number_format( $g_count ), bbp_number_format( $f_count ), bbp_number_format( $s_count ) ); 341 343 return array( 0, sprintf( $statement, $result ) ); 342 344 } … … 353 355 // Define variables 354 356 $bbp_db = bbp_db(); 355 $statement = __( 'Upgrading user favorites… %s', 'bbpress' );356 $result = __( 'No favorites to upgrade.','bbpress' );357 $statement = esc_html__( 'Upgrading user favorites… %s', 'bbpress' ); 358 $result = esc_html__( 'No favorites to upgrade.', 'bbpress' ); 357 359 $total = 0; 358 $key = $bbp_db->prefix . '_bbp_favorites'; 359 $favs = $bbp_db->get_results( $bbp_db->prepare( "SELECT * FROM {$bbp_db->usermeta} WHERE meta_key = %s", $key ) ); 360 $old_key = $bbp_db->prefix . '_bbp_favorites'; 361 $new_key = '_bbp_favorite'; 362 363 // Results 364 $query = "SELECT * FROM {$bbp_db->usermeta} WHERE meta_key = %s"; 365 $prepare = $bbp_db->prepare( $query, $old_key ); 366 $favs = $bbp_db->get_results( $prepare ); 360 367 361 368 // Bail if no closed topics found … … 374 381 375 382 // Skip if already exists 376 if ( $bbp_db->get_var( $bbp_db->prepare( "SELECT COUNT(*) FROM {$bbp_db->postmeta} WHERE post_id = %d AND meta_key = %s AND meta_value = %d", $post_id, '_bbp_favorite', $meta->user_id ) ) ) {383 if ( $bbp_db->get_var( $bbp_db->prepare( "SELECT COUNT(*) FROM {$bbp_db->postmeta} WHERE post_id = %d AND meta_key = %s AND meta_value = %d", $post_id, $new_key, $meta->user_id ) ) ) { 377 384 continue; 378 385 } 379 386 380 387 // Add the post meta 381 $added = add_post_meta( $post_id, '_bbp_favorite', $meta->user_id, false );388 $added = add_post_meta( $post_id, $new_key, $meta->user_id, false ); 382 389 383 390 // Bump counts if successfully added … … 408 415 // Define variables 409 416 $bbp_db = bbp_db(); 410 $statement = __( 'Upgrading user topic subscriptions… %s', 'bbpress' );411 $result = __( 'No topic subscriptions to upgrade.','bbpress' );417 $statement = esc_html__( 'Upgrading user topic subscriptions… %s', 'bbpress' ); 418 $result = esc_html__( 'No topic subscriptions to upgrade.', 'bbpress' ); 412 419 $total = 0; 413 $key = $bbp_db->prefix . '_bbp_subscriptions'; 414 $subs = $bbp_db->get_results( $bbp_db->prepare( "SELECT * FROM {$bbp_db->usermeta} WHERE meta_key = %s ORDER BY user_id", $key ) ); 420 $old_key = $bbp_db->prefix . '_bbp_subscriptions'; 421 $new_key = '_bbp_subscription'; 422 423 // Results 424 $query = "SELECT * FROM {$bbp_db->usermeta} WHERE meta_key = %s ORDER BY user_id"; 425 $prepare = $bbp_db->prepare( $query, $old_key ); 426 $subs = $bbp_db->get_results( $prepare ); 415 427 416 428 // Bail if no topic subscriptions found … … 429 441 430 442 // Skip if already exists 431 if ( $bbp_db->get_var( $bbp_db->prepare( "SELECT COUNT(*) FROM {$bbp_db->postmeta} WHERE post_id = %d AND meta_key = %s AND meta_value = %d", $post_id, '_bbp_subscription', $meta->user_id ) ) ) {443 if ( $bbp_db->get_var( $bbp_db->prepare( "SELECT COUNT(*) FROM {$bbp_db->postmeta} WHERE post_id = %d AND meta_key = %s AND meta_value = %d", $post_id, $new_key, $meta->user_id ) ) ) { 432 444 continue; 433 445 } 434 446 435 447 // Add the post meta 436 $added = add_post_meta( $post_id, '_bbp_subscription', $meta->user_id, false );448 $added = add_post_meta( $post_id, $new_key, $meta->user_id, false ); 437 449 438 450 // Bump counts if successfully added … … 463 475 // Define variables 464 476 $bbp_db = bbp_db(); 465 $statement = __( 'Upgrading user forum subscriptions… %s', 'bbpress' );466 $result = __( 'No forum subscriptions to upgrade.','bbpress' );477 $statement = esc_html__( 'Upgrading user forum subscriptions… %s', 'bbpress' ); 478 $result = esc_html__( 'No forum subscriptions to upgrade.', 'bbpress' ); 467 479 $total = 0; 468 $key = $bbp_db->prefix . '_bbp_forum_subscriptions'; 469 $subs = $bbp_db->get_results( $bbp_db->prepare( "SELECT * FROM {$bbp_db->usermeta} WHERE meta_key = %s ORDER BY user_id", $key ) ); 480 $old_key = $bbp_db->prefix . '_bbp_forum_subscriptions'; 481 $new_key = '_bbp_subscription'; 482 483 // Results 484 $query = "SELECT * FROM {$bbp_db->usermeta} WHERE meta_key = %s ORDER BY user_id"; 485 $prepare = $bbp_db->prepare( $query, $old_key ); 486 $subs = $bbp_db->get_results( $prepare ); 470 487 471 488 // Bail if no forum subscriptions found … … 484 501 485 502 // Skip if already exists 486 if ( $bbp_db->get_var( $bbp_db->prepare( "SELECT COUNT(*) FROM {$bbp_db->postmeta} WHERE post_id = %d AND meta_key = %s AND meta_value = %d", $post_id, '_bbp_forum_subscription', $meta->user_id ) ) ) {503 if ( $bbp_db->get_var( $bbp_db->prepare( "SELECT COUNT(*) FROM {$bbp_db->postmeta} WHERE post_id = %d AND meta_key = %s AND meta_value = %d", $post_id, $new_key, $meta->user_id ) ) ) { 487 504 continue; 488 505 } 489 506 490 507 // Add the post meta 491 $added = add_post_meta( $post_id, '_bbp_subscription', $meta->user_id, false );508 $added = add_post_meta( $post_id, $new_key, $meta->user_id, false ); 492 509 493 510 // Bump counts if successfully added … … 508 525 509 526 /** 510 * Remove favorites data from wp_usermeta for bbPress 2.6 and higher527 * Remove favorites data from user meta for bbPress 2.6 and higher 511 528 * 512 529 * @since 2.6.0 bbPress (r6281) … … 518 535 // Define variables 519 536 $bbp_db = bbp_db(); 520 $statement = __( 'Remove favorites from usermeta… %s', 'bbpress' );521 $result = __( 'No favorites to remove.','bbpress' );537 $statement = esc_html__( 'Remove favorites from usermeta… %s', 'bbpress' ); 538 $result = esc_html__( 'No favorites to remove.', 'bbpress' ); 522 539 $total = 0; 523 540 $key = $bbp_db->prefix . '_bbp_favorites'; 524 $favs = $bbp_db->get_results( $bbp_db->prepare( "SELECT * FROM {$bbp_db->usermeta} WHERE meta_key = %s ORDER BY user_id", $key ) ); 541 542 // Results 543 $query = "SELECT * FROM {$bbp_db->usermeta} WHERE meta_key = %s ORDER BY user_id"; 544 $prepare = $bbp_db->prepare( $query, $key ); 545 $favs = $bbp_db->get_results( $prepare ); 525 546 526 547 // Bail if no favorites found … … 528 549 return array( 1, sprintf( $statement, $result ) ); 529 550 } 551 552 delete_metadata( 'user', false, $meta_key, false, true ); 530 553 531 554 // Loop through each user's favorites … … 549 572 550 573 /** 551 * Remove topic subscriptions data from wp_usermeta for bbPress 2.6 and higher574 * Remove topic subscriptions data from user meta for bbPress 2.6 and higher 552 575 * 553 576 * @since 2.6.0 bbPress (r6281) … … 559 582 // Define variables 560 583 $bbp_db = bbp_db(); 561 $statement = __( 'Remove topic subscriptions from usermeta… %s', 'bbpress' );562 $result = __( 'No topic subscriptions to remove.','bbpress' );584 $statement = esc_html__( 'Remove topic subscriptions from usermeta… %s', 'bbpress' ); 585 $result = esc_html__( 'No topic subscriptions to remove.', 'bbpress' ); 563 586 $total = 0; 564 587 $key = $bbp_db->prefix . '_bbp_subscriptions'; 565 $subs = $bbp_db->get_results( $bbp_db->prepare( "SELECT * FROM {$bbp_db->usermeta} WHERE meta_key = %s ORDER BY user_id", $key ) ); 588 589 // Results 590 $query = "SELECT * FROM {$bbp_db->usermeta} WHERE meta_key = %s ORDER BY user_id"; 591 $prepare = $bbp_db->prepare( $query, $key ); 592 $subs = $bbp_db->get_results( $prepare ); 566 593 567 594 // Bail if no forum favorites found … … 590 617 591 618 /** 592 * Remove topic subscriptions data from wp_usermeta for bbPress 2.6 and higher619 * Remove topic subscriptions data from user meta for bbPress 2.6 and higher 593 620 * 594 621 * @since 2.6.0 bbPress (r6281) … … 600 627 // Define variables 601 628 $bbp_db = bbp_db(); 602 $statement = __( 'Remove forum subscriptions from usermeta… %s', 'bbpress' );603 $result = __( 'No forum subscriptions to remove.','bbpress' );629 $statement = esc_html__( 'Remove forum subscriptions from usermeta… %s', 'bbpress' ); 630 $result = esc_html__( 'No forum subscriptions to remove.', 'bbpress' ); 604 631 $total = 0; 605 632 $key = $bbp_db->prefix . '_bbp_forum_subscriptions'; 606 $subs = $bbp_db->get_results( $bbp_db->prepare( "SELECT * FROM {$bbp_db->usermeta} WHERE meta_key = %s ORDER BY user_id", $key ) ); 633 634 // Query 635 $query = "SELECT * FROM {$bbp_db->usermeta} WHERE meta_key = %s ORDER BY user_id"; 636 $prepare = $bbp_db->prepare( $query, $key ); 637 $subs = $bbp_db->get_results( $prepare ); 607 638 608 639 // Bail if no forum favorites found
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)