Ticket #8687: 8687.trunk.patch
File 8687.trunk.patch, 8.0 KB (added by , 3 years ago) |
---|
-
src/bp-core/bp-core-functions.php
diff --git src/bp-core/bp-core-functions.php src/bp-core/bp-core-functions.php index d9e4a7eab..584725a43 100644
function bp_version() { 31 31 return buddypress()->version; 32 32 } 33 33 34 /** 35 * Output a BuddyPress major version. 36 * 37 * @since 11.0.0 38 * 39 * @param string $version BuddyPress version. 40 */ 41 function bp_major_version( $version = '' ) { 42 echo bp_get_major_version( $version ); 43 } 44 45 /** 46 * Return a BuddyPress major version. 47 * 48 * @since 11.0.0 49 * 50 * @param string $version BuddyPress version. 51 * @return string The corresponding BuddyPress major version. 52 */ 53 function bp_get_major_version( $version = '' ) { 54 if ( ! $version ) { 55 $version = bp_get_version(); 56 } 57 58 $last_wp_like_major_versions = '2.9'; 59 $float_version = (float) $version; 60 61 if ( 1 !== version_compare( $version, $last_wp_like_major_versions ) ) { 62 $major_version = (string) $float_version; 63 } else { 64 $major_version = (int) $float_version . '.0'; 65 } 66 67 return $major_version; 68 } 69 70 /** 71 * Output the BuddyPress version used for its first install. 72 * 73 * @since 11.0.0 74 */ 75 function bp_initial_version() { 76 echo bp_get_initial_version(); 77 } 78 79 /** 80 * Return the BuddyPress version used for its first install. 81 * 82 * @since 11.0.0 83 * 84 * @return string The BuddyPress version used for its first install. 85 */ 86 function bp_get_initial_version() { 87 return bp_get_option( '_bp_initial_major_version', '0' ); 88 } 89 34 90 /** 35 91 * Output the BuddyPress database version. 36 92 * -
src/bp-core/bp-core-options.php
diff --git src/bp-core/bp-core-options.php src/bp-core/bp-core-options.php index e539a06ff..19070b22f 100644
function bp_get_default_options() { 95 95 // Do not register the bp-default themes directory. 96 96 '_bp_retain_bp_default' => false, 97 97 98 // Ignore deprecated code.99 '_bp_ignore_deprecated_code' => true,100 101 98 /* Widgets **************************************************/ 102 99 'widget_bp_core_login_widget' => false, 103 100 'widget_bp_core_members_widget' => false, -
src/bp-core/bp-core-update.php
diff --git src/bp-core/bp-core-update.php src/bp-core/bp-core-update.php index 2651cc0c6..59258439d 100644
function bp_version_updater() { 206 206 // Install BP schema and activate only Activity and XProfile. 207 207 if ( bp_is_install() ) { 208 208 209 // Set the first BP major version the plugin was installed. 210 bp_update_option( '_bp_initial_major_version', bp_get_major_version() ); 211 209 212 // Apply schema and set Activity and XProfile components as active. 210 213 bp_core_install( $default_components ); 211 214 bp_update_option( 'bp-active-components', $default_components ); … … function bp_core_get_10_0_upgrade_email_schema( $emails ) { 761 764 * @since 11.0.0 762 765 */ 763 766 function bp_update_to_11_0() { 767 bp_delete_option( '_bp_ignore_deprecated_code' ); 764 768 765 769 add_filter( 'bp_email_get_schema', 'bp_core_get_11_0_upgrade_email_schema' ); 766 770 -
src/class-buddypress.php
diff --git src/class-buddypress.php src/class-buddypress.php index b291d956e..388c941a5 100644
class BuddyPress { 359 359 * 360 360 * @since 2.0.0 Defaults to false always 361 361 * @since 2.8.0 Defaults to true on upgrades, false for new installs. 362 * @since 11.0.0 Defaults to true, unless the BP_IGNORE_DEPRECATED constant says otherwise. 362 363 */ 363 $this->load_deprecated = false;364 $this->load_deprecated = defined( 'BP_IGNORE_DEPRECATED' ) ? ! BP_IGNORE_DEPRECATED : true; 364 365 365 366 /** Toolbar */ 366 367 … … class BuddyPress { 463 464 * @param string $value Email type taxonomy slug. 464 465 */ 465 466 $this->email_taxonomy_type = apply_filters( 'bp_email_tax_type', 'bp-email-type' ); 467 468 /** 469 * Are PHPUnit tests running? 470 * 471 * @since 11.0.0 472 * 473 * @param bool $value True if PHPUnit tests are running, false otherwise. 474 */ 475 $this->is_phpunit_running = function_exists( 'tests_add_filter' ); 466 476 } 467 477 468 478 /** … … class BuddyPress { 484 494 if ( ! defined( 'BP_DB_VERSION' ) ) { 485 495 define( 'BP_DB_VERSION', $this->db_version ); 486 496 } 487 488 // Define if deprecated functions should be ignored.489 if ( ! defined( 'BP_IGNORE_DEPRECATED' ) ) {490 define( 'BP_IGNORE_DEPRECATED', true );491 }492 497 } 493 498 494 499 /** … … class BuddyPress { 535 540 require $this->plugin_dir . 'bp-core/bp-core-rest-api.php'; 536 541 require $this->plugin_dir . 'bp-core/bp-core-blocks.php'; 537 542 538 // Maybe load deprecated functionality (this double negative is proof positive!). 539 if ( ! bp_get_option( '_bp_ignore_deprecated_code', ! $this->load_deprecated ) ) { 540 require $this->plugin_dir . 'bp-core/deprecated/1.2.php'; 541 require $this->plugin_dir . 'bp-core/deprecated/1.5.php'; 542 require $this->plugin_dir . 'bp-core/deprecated/1.6.php'; 543 require $this->plugin_dir . 'bp-core/deprecated/1.7.php'; 544 require $this->plugin_dir . 'bp-core/deprecated/1.9.php'; 545 require $this->plugin_dir . 'bp-core/deprecated/2.0.php'; 546 require $this->plugin_dir . 'bp-core/deprecated/2.1.php'; 547 require $this->plugin_dir . 'bp-core/deprecated/2.2.php'; 548 require $this->plugin_dir . 'bp-core/deprecated/2.3.php'; 549 require $this->plugin_dir . 'bp-core/deprecated/2.4.php'; 550 require $this->plugin_dir . 'bp-core/deprecated/2.5.php'; 551 require $this->plugin_dir . 'bp-core/deprecated/2.6.php'; 552 require $this->plugin_dir . 'bp-core/deprecated/2.7.php'; 553 require $this->plugin_dir . 'bp-core/deprecated/2.8.php'; 554 require $this->plugin_dir . 'bp-core/deprecated/2.9.php'; 555 require $this->plugin_dir . 'bp-core/deprecated/3.0.php'; 556 require $this->plugin_dir . 'bp-core/deprecated/4.0.php'; 557 require $this->plugin_dir . 'bp-core/deprecated/6.0.php'; 558 require $this->plugin_dir . 'bp-core/deprecated/7.0.php'; 559 require $this->plugin_dir . 'bp-core/deprecated/8.0.php'; 560 require $this->plugin_dir . 'bp-core/deprecated/9.0.php'; 561 require $this->plugin_dir . 'bp-core/deprecated/10.0.php'; 543 // Load deprecated functionality. 544 if ( $this->load_deprecated && ! $this->is_phpunit_running ) { 545 // Get the initial major version. 546 $first_major_version = bp_get_initial_version(); 547 548 // List of versions containing deprecated functions. 549 $deprecated_versions = array( 550 '1.2', 551 '1.5', 552 '1.6', 553 '1.7', 554 '1.9', 555 '2.0', 556 '2.1', 557 '2.2', 558 '2.3', 559 '2.4', 560 '2.5', 561 '2.6', 562 '2.7', 563 '2.8', 564 '2.9', 565 '3.0', 566 '4.0', 567 '6.0', 568 '7.0', 569 '8.0', 570 '9.0', 571 '10.0', 572 ); 573 574 foreach ( $deprecated_versions as $deprecated_version ) { 575 if ( 1 === version_compare( $first_major_version, $deprecated_version ) ) { 576 continue; 577 } 578 579 // Only load deprecated versions that are equals or higher than the first major version. 580 require $this->plugin_dir . sprintf( 'bp-core/deprecated/%s.php', $deprecated_version ); 581 } 562 582 } 563 583 564 584 // Load wp-cli module if PHP 5.6+. … … class BuddyPress { 719 739 if ( 720 740 ! in_array( $component, array( 'core', 'members' ), true ) && 721 741 ! bp_is_active( $component ) && 722 ! function_exists( 'tests_add_filter' )742 ! $this->is_phpunit_running 723 743 ) { 724 744 return; 725 745 } -
tests/phpunit/testcases/core/functions.php
diff --git tests/phpunit/testcases/core/functions.php tests/phpunit/testcases/core/functions.php index f3c20c1d8..dcbe0332f 100644
class BP_Tests_Core_Functions extends BP_UnitTestCase { 872 872 $bp->active_components = $reset_bp_active_components; 873 873 } 874 874 875 /** 876 * @ticket BP8687 877 */ 878 public function test_bp_get_major_version() { 879 $this->assertEquals( '2.6', bp_get_major_version( '2.6.1.1' ) ); 880 $this->assertEquals( '3.0', bp_get_major_version( '3.1.0' ) ); 881 $this->assertEquals( '9.0', bp_get_major_version( '9' ) ); 882 $this->assertEquals( '10.0', bp_get_major_version( '10.0.0' ) ); 883 } 884 875 885 public function add_newcomponent_page_title( $page_default_titles = array() ) { 876 886 return array_merge( $page_default_titles, array( 'newcomponent' => 'NewComponent' ) ); 877 887 }