mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
WP_Filesystem: Ensure that all files are read/written correctly by verifying the return values from fwrite() and using FTP_BINARY mode (ASCII converts line endings as per the spec). See #25237
git-svn-id: https://develop.svn.wordpress.org/trunk@25304 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -59,12 +59,20 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
||||
* @param int $mode (optional) The file permissions as octal number, usually 0644.
|
||||
* @return bool False upon failure.
|
||||
*/
|
||||
function put_contents($file, $contents, $mode = false ) {
|
||||
if ( ! ($fp = @fopen($file, 'w')) )
|
||||
function put_contents( $file, $contents, $mode = false ) {
|
||||
$fp = @fopen( $file, 'wb' );
|
||||
if ( ! $fp )
|
||||
return false;
|
||||
@fwrite($fp, $contents);
|
||||
@fclose($fp);
|
||||
$this->chmod($file, $mode);
|
||||
|
||||
$bytes_written = fwrite( $fp, $contents );
|
||||
|
||||
fclose( $fp );
|
||||
|
||||
if ( false === $bytes_written || $bytes_written != strlen( $contents ) )
|
||||
return false;
|
||||
|
||||
$this->chmod( $file, $mode );
|
||||
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user