Making WordPress.org

Changeset 12175


Ignore:
Timestamp:
11/01/2022 05:41:04 AM (20 months ago)
Author:
dd32
Message:

Plugin Directory: Don't delete submitted ZIP files immediately upon approval/rejection, and instead delete them x days afterwards.

This provides some room for re-reviewing recently-rejected or recently-approved plugins when required.

Closes https://github.com/WordPress/wordpress.org/pull/106.
Fixes #5636.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
Files:
3 edited

Legend:

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

    r11770 r12175  
    203203     */
    204204    public function approved( $post_id, $post ) {
    205         $attachments   = get_attached_media( 'application/zip', $post_id );
    206205        $plugin_author = get_user_by( 'id', $post->post_author );
    207206
     
    214213        /*
    215214         Temporarily disable SVN prefill from ZIP files
     215        $attachments = get_attached_media( 'application/zip', $post_id );
    216216        if ( $attachments ) {
    217217            $attachment = end( $attachments );
     
    229229        SVN::import( $dir, 'http://plugins.svn.wordpress.org/' . $post->post_name, sprintf( 'Adding %1$s by %2$s.', $post->post_title, $plugin_author->user_login ) );
    230230
    231         // Delete zips.
    232         foreach ( $attachments as $attachment ) {
    233             wp_delete_attachment( $attachment->ID, true );
    234         }
    235 
    236231        // Grant commit access.
    237232        Tools::grant_plugin_committer( $post->post_name, $plugin_author );
     
    255250        $original_permalink = $post->post_name;
    256251        $submission_date    = get_the_modified_date( 'F j, Y', $post_id );
    257 
    258         // Delete zips.
    259         foreach ( get_attached_media( 'application/zip', $post_id ) as $attachment ) {
    260             wp_delete_attachment( $attachment->ID, true );
    261         }
    262252
    263253        // Change slug to 'rejected-plugin-name-rejected' to free up 'plugin-name'.
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-review-tools.php

    r12166 r12175  
    113113        ] );
    114114
    115         if ( in_array( $post->post_status, [ 'draft', 'pending', 'new' ], true ) ) {
    116 
    117             $zip_files = array();
    118             foreach ( get_attached_media( 'application/zip', $post ) as $zip_file ) {
    119                 $zip_files[ $zip_file->post_date ] = array( wp_get_attachment_url( $zip_file->ID ), $zip_file );
    120             }
     115        $zip_files = array();
     116        foreach ( get_attached_media( 'application/zip', $post ) as $zip_file ) {
     117            $zip_files[ $zip_file->post_date ] = array( wp_get_attachment_url( $zip_file->ID ), $zip_file );
     118        }
     119
     120        if ( $zip_files ) {
    121121            uksort( $zip_files, function ( $a, $b ) {
    122122                return strtotime( $a ) < strtotime( $b );
    123123            } );
    124 
    125             $zip_url = get_post_meta( $post->ID, '_submitted_zip', true );
    126             if ( $zip_url ) {
    127                 // Back-compat only.
    128                 $zip_files['User provided URL'] = array( $zip_url, null );
    129             }
    130124
    131125            echo '<p><strong>Zip files:</strong></p>';
     
    133127            foreach ( $zip_files as $zip_date => $zip ) {
    134128                list( $zip_url, $zip_file ) = $zip;
    135                 $zip_size                   = is_object( $zip_file ) ? size_format( filesize( get_attached_file( $zip_file->ID ) ), 1 ) : 'unknown size';
    136 
    137                 printf( '<li>%s <a href="%s">%s</a> (%s)</li>', esc_html( $zip_date ), esc_url( $zip_url ), esc_html( $zip_url ), esc_html( $zip_size ) );
     129                $zip_size                   = size_format( filesize( get_attached_file( $zip_file->ID ) ), 1 );
     130
     131                printf(
     132                    '<li>%1$s <a href="%2$s">%3$s</a> (%4$s)</li>',
     133                    esc_html( $zip_date ),
     134                    esc_url( $zip_url ),
     135                    esc_html( basename( $zip_url ) ),
     136                    esc_html( $zip_size )
     137                );
    138138            }
    139139            echo '</ul>';
    140 
     140        }
     141
     142        if ( in_array( $post->post_status, [ 'draft', 'pending', 'new' ], true ) ) {
    141143            $slug_restricted = [];
    142144            $slug_reserved   = [];
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/jobs/class-manager.php

    r10230 r12175  
    2424        add_action( 'plugin_directory_update_api_check', array( __NAMESPACE__ . '\API_Update_Updater', 'cron_trigger' ) );
    2525        add_action( 'plugin_directory_translation_sync', array( __NAMESPACE__ . '\Translation_Sync', 'cron_trigger' ) );
     26        add_action( 'plugin_directory_zip_cleanup', array( __NAMESPACE__ . '\Zip_Cleanup', 'cron_trigger' ) );
    2627
    2728        // A cronjob to check cronjobs
     
    259260            wp_schedule_event( time() + 60, 'daily', 'plugin_directory_translation_sync' );
    260261        }
     262        if ( ! wp_next_scheduled ( 'plugin_directory_zip_cleanup' ) ) {
     263            wp_schedule_event( time() + 60, 'daily', 'plugin_directory_zip_cleanup' );
     264        }
    261265
    262266        // Check to see if `WP_CORE_LATEST_RELEASE` has changed since we last ran.
Note: See TracChangeset for help on using the changeset viewer.