Making WordPress.org


Ignore:
Timestamp:
04/12/2024 03:37:30 AM (11 months ago)
Author:
dd32
Message:

Plugin Directory: Avoid PHP Warnings when the uploaded file doesn't exist.

File:
1 edited

Legend:

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

    r13113 r13505  
    115115        $zip_files = array();
    116116        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 );
     117            $zip_files[ $zip_file->post_date ] = array(
     118                wp_get_attachment_url( $zip_file->ID ),
     119                $zip_file,
     120                get_attached_file( $zip_file->ID )
     121            );
    118122        }
    119123
     
    126130            echo '<ul class="plugin-zip-files">';
    127131            foreach ( $zip_files as $zip_date => $zip ) {
    128                 list( $zip_url, $zip_file ) = $zip;
    129                 $zip_size                   = size_format( filesize( get_attached_file( $zip_file->ID ) ), 1 );
    130                 $zip_preview                = Template::preview_link_zip( $slug, $zip_file->ID );
    131                 $zip_pcp                    = Template::preview_link_zip( $slug, $zip_file->ID, 'pcp' );
     132                list( $zip_url, $zip_file, $file_on_disk ) = $zip;
     133
     134                if ( ! file_exists( $file_on_disk ) ) {
     135                    continue;
     136                }
     137
     138                $zip_size    = size_format( filesize( $file_on_disk ), 1 );
     139                $zip_preview = Template::preview_link_zip( $slug, $zip_file->ID );
     140                $zip_pcp     = Template::preview_link_zip( $slug, $zip_file->ID, 'pcp' );
    132141
    133142                printf(
Note: See TracChangeset for help on using the changeset viewer.