Skip to:
Content

BuddyPress.org

Ticket #8687: 8687.branch-10.0.patch

File 8687.branch-10.0.patch, 4.9 KB (added by imath, 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..9744a02d5 100644
    function bp_version() { 
    3131                return buddypress()->version;
    3232        }
    3333
     34/**
     35 * Output the BuddyPress version used for its first install.
     36 *
     37 * @since 10.3.0
     38 */
     39function bp_initial_version() {
     40        echo bp_get_initial_version();
     41}
     42
     43        /**
     44         * Return the BuddyPress version used for its first install.
     45         *
     46         * @since 10.3.0
     47         *
     48         * @return string The BuddyPress version used for its first install.
     49         */
     50        function bp_get_initial_version() {
     51                return bp_get_option( '_bp_initial_major_version', '0' );
     52        }
     53
    3454/**
    3555 * Output the BuddyPress database version.
    3656 *
  • src/class-buddypress.php

    diff --git src/class-buddypress.php src/class-buddypress.php
    index b291d956e..44c47e29d 100644
    class BuddyPress { 
    359359                 *
    360360                 * @since 2.0.0 Defaults to false always
    361361                 * @since 2.8.0 Defaults to true on upgrades, false for new installs.
     362                 * @since 10.3.0 Defaults to true, unless the BP_IGNORE_DEPRECATED constant says otherwise.
    362363                 */
    363                 $this->load_deprecated = false;
     364                $this->load_deprecated = defined( 'BP_IGNORE_DEPRECATED' ) ? ! BP_IGNORE_DEPRECATED : true;
    364365
    365366                /** Toolbar */
    366367
    class BuddyPress { 
    463464                 * @param string $value Email type taxonomy slug.
    464465                 */
    465466                $this->email_taxonomy_type = apply_filters( 'bp_email_tax_type', 'bp-email-type' );
     467
     468                /**
     469                 * Are PHPUnit tests running?
     470                 *
     471                 * @since 10.3.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' );
    466476        }
    467477
    468478        /**
    class BuddyPress { 
    484494                if ( ! defined( 'BP_DB_VERSION' ) ) {
    485495                        define( 'BP_DB_VERSION', $this->db_version );
    486496                }
    487 
    488                 // Define if deprecated functions should be ignored.
    489                 if ( ! defined( 'BP_IGNORE_DEPRECATED' ) ) {
    490                         define( 'BP_IGNORE_DEPRECATED', true );
    491                 }
    492497        }
    493498
    494499        /**
    class BuddyPress { 
    535540                require $this->plugin_dir . 'bp-core/bp-core-rest-api.php';
    536541                require $this->plugin_dir . 'bp-core/bp-core-blocks.php';
    537542
    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                        }
    562582                }
    563583
    564584                // Load wp-cli module if PHP 5.6+.
    class BuddyPress { 
    719739                if (
    720740                        ! in_array( $component, array( 'core', 'members' ), true ) &&
    721741                        ! bp_is_active( $component ) &&
    722                         ! function_exists( 'tests_add_filter' )
     742                        ! $this->is_phpunit_running
    723743                ) {
    724744                        return;
    725745                }