Making WordPress.org

Changeset 13637


Ignore:
Timestamp:
05/01/2024 01:51:39 AM (7 weeks ago)
Author:
dd32
Message:

Plugin Directory: Support the Tested Up To header in the main plugin file.

This is as the other similar metadata fields are preferred from the plugin file, so it makes sense to have all versions co-located.

Fixes #4621.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php

    r13551 r13637  
    2929    // Readme fields which get stored in plugin meta
    3030    public $readme_fields = array(
    31         'tested',
    3231        'donate_link',
    3332        'license',
     
    3736
    3837        // These headers are stored as post meta, but are handled separately.
     38        // 'tested',
    3939        // 'requires',
    4040        // 'requires_php',
     
    320320        }
    321321
    322         // Update the tested-up-to value
    323         $tested = $readme->tested;
    324         if ( function_exists( 'wporg_get_version_equivalents' ) ) {
    325             foreach ( wporg_get_version_equivalents() as $latest_compatible_version => $compatible_with ) {
    326                 if ( in_array( $readme->tested, $compatible_with, true ) ) {
    327                     $tested = $latest_compatible_version;
    328                     break;
    329                 }
    330             }
    331         }
    332 
    333322        // Update all readme meta
    334323        foreach ( $this->readme_fields as $readme_field ) {
    335             $value = ( 'tested' == $readme_field ) ? $tested : $readme->$readme_field;
    336             update_post_meta( $plugin->ID, $readme_field, wp_slash( $value ) );
     324            update_post_meta( $plugin->ID, $readme_field, wp_slash( $readme->$readme_field ) );
    337325        }
    338326
     
    342330        }
    343331
    344         // Update the Requires and Requires PHP fields, prefering those from the Plugin Headers.
     332        // Update the Requires, Requires PHP, and Tested up to fields, prefering those from the Plugin Headers.
    345333        // Unfortunately the value within $headers is not always a well-formed value.
    346334        $requires     = $readme->requires;
    347335        $requires_php = $readme->requires_php;
     336        $tested       = $readme->tested;
    348337        if ( $headers->RequiresWP && preg_match( '!^[\d.]{3,}$!', $headers->RequiresWP ) ) {
    349338            $requires = $headers->RequiresWP;
     
    351340        if ( $headers->RequiresPHP && preg_match( '!^[\d.]{3,}$!', $headers->RequiresPHP ) ) {
    352341            $requires_php = $headers->RequiresPHP;
     342        }
     343        if ( $headers->TestedUpTo && preg_match( '!^[\d.]{3,}$!', $headers->TestedUpTo ) ) {
     344            $tested = $headers->TestedUpTo;
     345        }
     346
     347        // Sanitize the tested version.
     348        if ( function_exists( 'wporg_get_version_equivalents' ) ) {
     349            foreach ( wporg_get_version_equivalents() as $latest_compatible_version => $compatible_with ) {
     350                if ( in_array( $tested, $compatible_with, true ) ) {
     351                    $tested = $latest_compatible_version;
     352                    break;
     353                }
     354            }
    353355        }
    354356
     
    364366        update_post_meta( $plugin->ID, 'requires',           wp_slash( $requires ) );
    365367        update_post_meta( $plugin->ID, 'requires_php',       wp_slash( $requires_php ) );
     368        update_post_meta( $plugin->ID, 'tested',             wp_slash( $tested ) );
    366369        update_post_meta( $plugin->ID, 'tagged_versions',    wp_slash( array_keys( $tagged_versions ) ) );
    367370        update_post_meta( $plugin->ID, 'sections',           wp_slash( array_keys( $readme->sections ) ) );
     
    973976        if ( ! isset( $headers['RequiresPlugins'] ) ) {
    974977            $headers['RequiresPlugins'] = 'Requires Plugins';
     978        }
     979        // https://meta.trac.wordpress.org/ticket/4621
     980        if ( ! isset( $headers['TestedUpTo'] ) ) {
     981            $headers['TestedUpTo'] = 'Tested up to';
    975982        }
    976983
Note: See TracChangeset for help on using the changeset viewer.