Make WordPress Core


Ignore:
Timestamp:
07/18/2016 07:42:48 PM (10 years ago)
Author:
ocean90
Message:

Filesystem API: Cleanup temporary file when the temporary file couldn't be opened.

Props ruud@joyo.
See #34772.
Fixes #36942, #36943.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-filesystem-ftpext.php

    r35944 r38094  
    121121                        return false;
    122122                }
    123                
     123
    124124                if ( ! @ftp_fget( $this->link, $temp, $file, FTP_BINARY ) ) {
    125125                        fclose( $temp );
    … …  
    127127                        return false;
    128128                }
    129                
     129
    130130                fseek( $temp, 0 ); // Skip back to the start of the file being written to
    131131                $contents = '';
    … …  
    160160                $tempfile = wp_tempnam($file);
    161161                $temp = fopen( $tempfile, 'wb+' );
    162                 if ( ! $temp )
    163                         return false;
     162
     163                if ( ! $temp ) {
     164                        unlink( $tempfile );
     165                        return false;
     166                }
    164167
    165168                mbstring_binary_safe_encoding();
Note: See TracChangeset for help on using the changeset viewer.