Ticket #10889: 10889.3.diff
| File 10889.3.diff, 4.5 KB (added by dd32, 3 years ago) |
|---|
-
wp-admin/includes/class-wp-filesystem-direct.php
54 54 /** 55 55 * Write a string to a file 56 56 * 57 * @param $file string Path to the file where to write the data.57 * @param $file string Remote path to the file where to write the data. 58 58 * @param $contents string The data to write. 59 59 * @param $mode int (optional) The file permissions as octal number, usually 0644. 60 * @param $type string (optional) Specifies additional type of access you require to the file.61 60 * @return bool False upon failure. 62 61 */ 63 function put_contents($file, $contents, $mode = false , $type = '') {64 if ( ! ($fp = @fopen($file, 'w' . $type)) )62 function put_contents($file, $contents, $mode = false ) { 63 if ( ! ($fp = @fopen($file, 'w')) ) 65 64 return false; 66 65 @fwrite($fp, $contents); 67 66 @fclose($fp); -
wp-admin/includes/class-wp-filesystem-ftpext.php
111 111 function get_contents_array($file) { 112 112 return explode("\n", $this->get_contents($file)); 113 113 } 114 function put_contents($file, $contents, $type = '' ) { 115 if ( empty($type) ) 116 $type = $this->is_binary($contents) ? FTP_BINARY : FTP_ASCII; 117 114 115 function put_contents($file, $contents, $mode = false ) { 118 116 $temp = tmpfile(); 119 117 if ( ! $temp ) 120 118 return false; … … 122 120 fwrite($temp, $contents); 123 121 fseek($temp, 0); //Skip back to the start of the file being written to 124 122 123 $type = $this->is_binary($contents) ? FTP_BINARY : FTP_ASCII; 125 124 $ret = @ftp_fput($this->link, $file, $temp, $type); 126 125 127 126 fclose($temp); 127 128 $this->chmod($file, $mode); 129 128 130 return $ret; 129 131 } 130 132 function cwd() { -
wp-admin/includes/class-wp-filesystem-ftpsockets.php
115 115 return explode("\n", $this->get_contents($file) ); 116 116 } 117 117 118 function put_contents($file, $contents, $type = '' ) { 119 if ( empty($type) ) 120 $type = $this->is_binary($contents) ? FTP_BINARY : FTP_ASCII; 121 122 $this->ftp->SetType($type); 123 118 function put_contents($file, $contents, $mode = false ) { 124 119 $temp = wp_tempnam( $file ); 125 if ( ! $temphandle = fopen($temp, 'w+') ) {120 if ( ! $temphandle = @fopen($temp, 'w+') ) { 126 121 unlink($temp); 127 122 return false; 128 123 } … … 130 125 fwrite($temphandle, $contents); 131 126 fseek($temphandle, 0); //Skip back to the start of the file being written to 132 127 128 $type = $this->is_binary($contents) ? FTP_BINARY : FTP_ASCII; 129 $this->ftp->SetType($type); 130 133 131 $ret = $this->ftp->fput($file, $temphandle); 134 132 135 133 fclose($temphandle); 136 134 unlink($temp); 135 136 $this->chmod($file, $mode); 137 137 138 return $ret; 138 139 } 139 140 -
wp-admin/includes/class-wp-filesystem-ssh2.php
160 160 return file('ssh2.sftp://' . $this->sftp_link . '/' . $file); 161 161 } 162 162 163 function put_contents($file, $contents, $ type = '') {163 function put_contents($file, $contents, $mode = false ) { 164 164 $file = ltrim($file, '/'); 165 return false !== file_put_contents('ssh2.sftp://' . $this->sftp_link . '/' . $file, $contents); 165 $ret = file_put_contents('ssh2.sftp://' . $this->sftp_link . '/' . $file, $contents); 166 167 $this->chmod($file, $mode); 168 169 return false !== $ret; 166 170 } 167 171 168 172 function cwd() { -
wp-admin/includes/file.php
546 546 547 547 // We've made sure the folders are there, so let's extract the file now: 548 548 if ( ! $file['folder'] ) { 549 if ( !$fs->put_contents( $to . $file['filename'], $file['content'] ) )549 if ( !$fs->put_contents( $to . $file['filename'], $file['content'], FS_CHMOD_FILE) ) 550 550 return new WP_Error('copy_failed', __('Could not copy file'), $to . $file['filename']); 551 $fs->chmod($to . $file['filename'], FS_CHMOD_FILE);552 551 } 553 552 } 554 553 return true;
