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

Props ruud@joyo.
See #34772.
Fixes #36942, #36943.
Built from https://develop.svn.wordpress.org/trunk@38094


git-svn-id: http://core.svn.wordpress.org/trunk@38035 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dominik Schilling 2016-07-18 19:43:30 +00:00
parent ee20f7606b
commit d59bcc98df
3 changed files with 10 additions and 5 deletions

View File

@ -120,13 +120,13 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
unlink( $tempfile );
return false;
}
if ( ! @ftp_fget( $this->link, $temp, $file, FTP_BINARY ) ) {
fclose( $temp );
unlink( $tempfile );
return false;
}
fseek( $temp, 0 ); // Skip back to the start of the file being written to
$contents = '';
@ -159,8 +159,11 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
public function put_contents($file, $contents, $mode = false ) {
$tempfile = wp_tempnam($file);
$temp = fopen( $tempfile, 'wb+' );
if ( ! $temp )
if ( ! $temp ) {
unlink( $tempfile );
return false;
}
mbstring_binary_safe_encoding();

View File

@ -121,8 +121,10 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
$temp = wp_tempnam( $file );
if ( ! $temphandle = fopen($temp, 'w+') )
if ( ! $temphandle = fopen( $temp, 'w+' ) ) {
unlink( $temp );
return false;
}
mbstring_binary_safe_encoding();

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.6-beta3-38093';
$wp_version = '4.6-beta3-38094';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.