mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-10-06 15:47:05 +00:00
Standardise WP_Filesystem_*::put_contents() arguments to support chmod reliably across all transports. Fixes #10889
git-svn-id: https://develop.svn.wordpress.org/trunk@12723 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -115,14 +115,9 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
return explode("\n", $this->get_contents($file) );
|
||||
}
|
||||
|
||||
function put_contents($file, $contents, $type = '' ) {
|
||||
if ( empty($type) )
|
||||
$type = $this->is_binary($contents) ? FTP_BINARY : FTP_ASCII;
|
||||
|
||||
$this->ftp->SetType($type);
|
||||
|
||||
function put_contents($file, $contents, $mode = false ) {
|
||||
$temp = wp_tempnam( $file );
|
||||
if ( ! $temphandle = fopen($temp, 'w+') ) {
|
||||
if ( ! $temphandle = @fopen($temp, 'w+') ) {
|
||||
unlink($temp);
|
||||
return false;
|
||||
}
|
||||
@@ -130,10 +125,16 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
fwrite($temphandle, $contents);
|
||||
fseek($temphandle, 0); //Skip back to the start of the file being written to
|
||||
|
||||
$type = $this->is_binary($contents) ? FTP_BINARY : FTP_ASCII;
|
||||
$this->ftp->SetType($type);
|
||||
|
||||
$ret = $this->ftp->fput($file, $temphandle);
|
||||
|
||||
fclose($temphandle);
|
||||
unlink($temp);
|
||||
|
||||
$this->chmod($file, $mode);
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user