Filesystem API: Cleanup temporary file when the temporary file couldn't be opened.
Props ruud@joyo. See #34772. Fixes #36942, #36943. git-svn-id: https://develop.svn.wordpress.org/trunk@38094 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
b55afe7f4d
commit
ff6d8819e4
@ -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();
|
||||
|
||||
|
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user