| @@ -12,9 +12,9 @@ | ||
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * If there is no raw DB version, this is the first installation |
| 15 | 15 | * |
| 16 | - * @since 2.1.0 bbPress (r3764) | |
| 16 | + * @since 2.1.0 bbPress (r3765) | |
| 17 | 17 | * |
| 18 | 18 | * @return bool True if update, False if not |
| 19 | 19 | */ |
| 20 | 20 | function bbp_is_install() { |
| @@ -150,11 +150,28 @@ | ||
| 150 | 150 | /** |
| 151 | 151 | * Setup the bbPress updater |
| 152 | 152 | * |
| 153 | 153 | * @since 2.0.0 bbPress (r3419) |
| 154 | + * @since 2.6.19 bbPress (r7645) Moved to "bbp_current_screen" hook | |
| 155 | + * | |
| 156 | + * @param WP_Screen|null $current_screen Current admin screen. | |
| 154 | 157 | */ |
| 155 | -function bbp_setup_updater() { | |
| 158 | +function bbp_setup_updater( $current_screen = null ) { | |
| 159 | + global $pagenow; | |
| 156 | 160 | |
| 161 | + // Only run during a real site or network admin screen | |
| 162 | + if ( ! $current_screen instanceof WP_Screen || | |
| 163 | + ( ! $current_screen->in_admin( 'site' ) && ! $current_screen->in_admin( 'network' ) ) || | |
| 164 | + wp_doing_ajax() || | |
| 165 | + in_array( $pagenow, array( 'admin-ajax.php', 'admin-post.php' ), true ) ) { | |
| 166 | + return; | |
| 167 | + } | |
| 168 | + | |
| 169 | + // Only forum keymasters and site administrators may start an upgrade | |
| 170 | + if ( ! current_user_can( 'bbp_tools_upgrade_page' ) && ! current_user_can( 'manage_options' ) ) { | |
| 171 | + return; | |
| 172 | + } | |
| 173 | + | |
| 157 | 174 | // Bail if no update needed |
| 158 | 175 | if ( ! bbp_is_update() ) { |
| 159 | 176 | return; |
| 160 | 177 | } |
| @@ -166,9 +183,9 @@ | ||
| 166 | 183 | /** |
| 167 | 184 | * Runs when a new site is created in a multisite network, and bbPress is active |
| 168 | 185 | * on that site (hooked to `bbp_new_site`) |
| 169 | 186 | * |
| 170 | - * @since 2.6.0 bbPress (r6779) | |
| 187 | + * @since 2.6.0 bbPress (r6780) | |
| 171 | 188 | */ |
| 172 | 189 | function bbp_setup_new_site( $site_id = 0 ) { |
| 173 | 190 | |
| 174 | 191 | // Look for initial content |
| @@ -189,9 +206,9 @@ | ||
| 189 | 206 | |
| 190 | 207 | /** |
| 191 | 208 | * Create a default forum, topic, and reply |
| 192 | 209 | * |
| 193 | - * @since 2.1.0 bbPress (r3767) | |
| 210 | + * @since 2.1.0 bbPress (r3768) | |
| 194 | 211 | * |
| 195 | 212 | * @param array $args Array of arguments to override default values |
| 196 | 213 | */ |
| 197 | 214 | function bbp_create_initial_content( $args = array() ) { |
| @@ -280,9 +297,9 @@ | ||
| 280 | 297 | * |
| 281 | 298 | * This is most-often used when the data schema changes, but should also be used |
| 282 | 299 | * to correct issues with bbPress meta-data silently on software update. |
| 283 | 300 | * |
| 284 | - * @since 2.2.0 bbPress (r4104) | |
| 301 | + * @since 2.2.0 bbPress (r4105) | |
| 285 | 302 | */ |
| 286 | 303 | function bbp_version_updater() { |
| 287 | 304 | |
| 288 | 305 | // Get the raw database version |
| @@ -289,8 +306,12 @@ | ||
| 289 | 306 | $raw_db_version = (int) bbp_get_db_version_raw(); |
| 290 | 307 | |
| 291 | 308 | // Only run updater if previous installation exists |
| 292 | 309 | if ( ! empty( $raw_db_version ) ) { |
| 310 | + // Discard converter progress SQL saved by older password upgrades. | |
| 311 | + if ( $raw_db_version < 264 ) { | |
| 312 | + delete_option( '_bbp_converter_query' ); | |
| 313 | + } | |
| 293 | 314 | |
| 294 | 315 | /** 2.0 Branch ********************************************************/ |
| 295 | 316 | |
| 296 | 317 | // 2.0, 2.0.1, 2.0.2, 2.0.3 |
| @@ -421,9 +442,9 @@ | ||
| 421 | 442 | |
| 422 | 443 | /** |
| 423 | 444 | * Redirect user to the "What's New" page on activation |
| 424 | 445 | * |
| 425 | - * @since 2.2.0 bbPress (r4389) | |
| 446 | + * @since 2.2.0 bbPress (r4390) | |
| 426 | 447 | * |
| 427 | 448 | * @internal Used internally to redirect bbPress to the about page on activation |
| 428 | 449 | * |
| 429 | 450 | * @return If network admin or bulk activation |
| @@ -441,9 +462,9 @@ | ||
| 441 | 462 | |
| 442 | 463 | /** |
| 443 | 464 | * Redirect user to "What's New" page on activation |
| 444 | 465 | * |
| 445 | - * @since 2.2.0 bbPress (r4389) | |
| 466 | + * @since 2.2.0 bbPress (r4390) | |
| 446 | 467 | * |
| 447 | 468 | * @internal Used internally to redirect bbPress to the about page on activation |
| 448 | 469 | * |
| 449 | 470 | * @return If no transient, or in network admin, or is bulk activation |
| @@ -528,9 +549,9 @@ | ||
| 528 | 549 | |
| 529 | 550 | /** |
| 530 | 551 | * Return the number of pending upgrades |
| 531 | 552 | * |
| 532 | - * @since 2.6.0 bbPress (r6895) | |
| 553 | + * @since 2.6.0 bbPress (r6896) | |
| 533 | 554 | * |
| 534 | 555 | * @param string $type Type of pending upgrades (upgrade|repair|empty) |
| 535 | 556 | * |
| 536 | 557 | * @return int |
| @@ -541,9 +562,9 @@ | ||
| 541 | 562 | |
| 542 | 563 | /** |
| 543 | 564 | * Return an array of pending upgrades |
| 544 | 565 | * |
| 545 | - * @since 2.6.0 bbPress (r6895) | |
| 566 | + * @since 2.6.0 bbPress (r6896) | |
| 546 | 567 | * |
| 547 | 568 | * @param string $type Type of pending upgrades (upgrade|repair|empty) |
| 548 | 569 | * |
| 549 | 570 | * @return array |
| @@ -565,9 +586,9 @@ | ||
| 565 | 586 | |
| 566 | 587 | /** |
| 567 | 588 | * Add an upgrade ID to pending upgrades array |
| 568 | 589 | * |
| 569 | - * @since 2.6.0 bbPress (r6895) | |
| 590 | + * @since 2.6.0 bbPress (r6896) | |
| 570 | 591 | * |
| 571 | 592 | * @param string $upgrade_id |
| 572 | 593 | */ |
| 573 | 594 | function bbp_add_pending_upgrade( $upgrade_id = '' ) { |
| @@ -586,9 +607,9 @@ | ||
| 586 | 607 | |
| 587 | 608 | /** |
| 588 | 609 | * Add an upgrade ID to pending upgrades array |
| 589 | 610 | * |
| 590 | - * @since 2.6.0 bbPress (r6895) | |
| 611 | + * @since 2.6.0 bbPress (r6896) | |
| 591 | 612 | * |
| 592 | 613 | * @param string $upgrade_id |
| 593 | 614 | */ |
| 594 | 615 | function bbp_remove_pending_upgrade( $upgrade_id = '' ) { |
| @@ -610,9 +631,9 @@ | ||
| 610 | 631 | |
| 611 | 632 | /** |
| 612 | 633 | * Delete all pending upgrades |
| 613 | 634 | * |
| 614 | - * @since 2.6.0 bbPress (r6895) | |
| 635 | + * @since 2.6.0 bbPress (r6896) | |
| 615 | 636 | */ |
| 616 | 637 | function bbp_clear_pending_upgrades() { |
| 617 | 638 | return delete_option( '_bbp_db_pending_upgrades' ); |
| 618 | 639 | } |
| @@ -619,9 +640,9 @@ | ||
| 619 | 640 | |
| 620 | 641 | /** |
| 621 | 642 | * Maybe append an upgrade count to a string |
| 622 | 643 | * |
| 623 | - * @since 2.6.0 bbPress (r6896) | |
| 644 | + * @since 2.6.0 bbPress (r6897) | |
| 624 | 645 | * |
| 625 | 646 | * @param string $string Text to append count to |
| 626 | 647 | * @param string $type Type of pending upgrades (upgrade|repair|empty) |
| 627 | 648 | * |