Making WordPress.org

Changeset 3782


Ignore:
Timestamp:
08/08/2016 12:23:26 AM (8 years ago)
Author:
obenland
Message:

Plugin Directory: Don't append tested version when it's within the last four releases.

Fixes a bug where the tested-up-to version was only compared with older
releases in the latest four branches and not the most current one when
determining whether the version needs to be appended or not.

Props joelcj91 for initial patch.
Fixes #1792.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-controls.php

    r3038 r3782  
    127127     * the current version the plugin is marked as tested with.
    128128     *
     129     * @global string $wp_version The WordPress version string.
     130     *
    129131     * @param string $tested_up_to The version which the plugin is currently specified as compatible to.
    130      *
    131132     * @return array An array containing 'versions' an array of versions for display, and 'tested_up_to'
    132133     *               the sanitized/most recent version of the $tested_up_to parameter.
     
    134135    protected static function get_tested_up_to_versions( $tested_up_to ) {
    135136        global $wp_version;
     137
    136138        // Fetch all "compatible" versions, this array is in the form of [ '4.4.2' => [ '4.4.1', '4.4' ], ...]
    137139        if ( function_exists( 'wporg_get_version_equivalents' ) ) {
     140
    138141            // This function is a global WordPress.org function.
    139142            $all_versions = wporg_get_version_equivalents();
     
    143146
    144147        $versions = array_slice( array_keys( $all_versions ), 0, 4 );
    145         // WordPress.org runs trunk, this keeps the highest version selectable as trunk
    146         $versions[5] = preg_replace( '!-\d{4,}$!', '', $wp_version );
    147148
    148         $found = false;
    149149        foreach( $versions as $version ) {
    150             if ( isset( $all_versions[ $version ] ) && in_array( $tested_up_to, $all_versions[ $version ] ) ) {
     150            if ( in_array( $tested_up_to, $all_versions[ $version ] ) ) {
    151151                $tested_up_to = $version;
    152                 $found = true;
    153152                break;
    154153            }
    155154        }
     155
    156156        // If the version specified isn't going to display, insert it into the list.
    157         if ( ! $found ) {
    158             $versions[4] = $tested_up_to;
    159             ksort( $versions );
     157        if ( ! in_array( $tested_up_to, $versions ) ) {
     158            $versions[] = $tested_up_to;
    160159        }
     160
     161        // WordPress.org runs trunk, this keeps the highest version selectable as trunk.
     162        $versions[] = preg_replace( '!-\d{4,}$!', '', $wp_version );
    161163
    162164        return compact( 'versions', 'tested_up_to' );
    163165    }
    164166}
    165 
Note: See TracChangeset for help on using the changeset viewer.