mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-13 05:10:18 +00:00
Coding Standards: Add some space around control structures in WP_Filesystem_* classes for consistency and better readability.
Additionally, synchronize `$tempfile` and `$temphandle` variable names in `WP_Filesystem_FTPext` and `WP_Filesystem_ftpsockets`. See #49542. git-svn-id: https://develop.svn.wordpress.org/trunk@48089 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -36,6 +36,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
if ( ! include_once ABSPATH . 'wp-admin/includes/class-ftp.php' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->ftp = new ftp();
|
||||
|
||||
if ( empty( $opt['port'] ) ) {
|
||||
@@ -87,6 +88,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
$this->options['hostname'] . ':' . $this->options['port']
|
||||
)
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -99,6 +101,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
$this->options['hostname'] . ':' . $this->options['port']
|
||||
)
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -111,12 +114,14 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
$this->options['username']
|
||||
)
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->ftp->SetType( FTP_BINARY );
|
||||
$this->ftp->Passive( true );
|
||||
$this->ftp->setTimeout( FS_TIMEOUT );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -134,11 +139,11 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
return false;
|
||||
}
|
||||
|
||||
$temp = wp_tempnam( $file );
|
||||
$tempfile = wp_tempnam( $file );
|
||||
$temphandle = fopen( $tempfile, 'w+' );
|
||||
|
||||
$temphandle = fopen( $temp, 'w+' );
|
||||
if ( ! $temphandle ) {
|
||||
unlink( $temp );
|
||||
unlink( $tempfile );
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -146,7 +151,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
|
||||
if ( ! $this->ftp->fget( $temphandle, $file ) ) {
|
||||
fclose( $temphandle );
|
||||
unlink( $temp );
|
||||
unlink( $tempfile );
|
||||
|
||||
reset_mbstring_encoding();
|
||||
|
||||
@@ -163,7 +168,8 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
}
|
||||
|
||||
fclose( $temphandle );
|
||||
unlink( $temp );
|
||||
unlink( $tempfile );
|
||||
|
||||
return $contents;
|
||||
}
|
||||
|
||||
@@ -191,10 +197,11 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function put_contents( $file, $contents, $mode = false ) {
|
||||
$temp = wp_tempnam( $file );
|
||||
$temphandle = @fopen( $temp, 'w+' );
|
||||
$tempfile = wp_tempnam( $file );
|
||||
$temphandle = @fopen( $tempfile, 'w+' );
|
||||
|
||||
if ( ! $temphandle ) {
|
||||
unlink( $temp );
|
||||
unlink( $tempfile );
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -202,9 +209,10 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
mbstring_binary_safe_encoding();
|
||||
|
||||
$bytes_written = fwrite( $temphandle, $contents );
|
||||
|
||||
if ( false === $bytes_written || strlen( $contents ) != $bytes_written ) {
|
||||
fclose( $temphandle );
|
||||
unlink( $temp );
|
||||
unlink( $tempfile );
|
||||
|
||||
reset_mbstring_encoding();
|
||||
|
||||
@@ -218,7 +226,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
reset_mbstring_encoding();
|
||||
|
||||
fclose( $temphandle );
|
||||
unlink( $temp );
|
||||
unlink( $tempfile );
|
||||
|
||||
$this->chmod( $file, $mode );
|
||||
|
||||
@@ -234,9 +242,11 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
*/
|
||||
public function cwd() {
|
||||
$cwd = $this->ftp->pwd();
|
||||
|
||||
if ( $cwd ) {
|
||||
$cwd = trailingslashit( $cwd );
|
||||
}
|
||||
|
||||
return $cwd;
|
||||
}
|
||||
|
||||
@@ -278,6 +288,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
// chmod any sub-objects if recursive.
|
||||
if ( $recursive && $this->is_dir( $file ) ) {
|
||||
$filelist = $this->dirlist( $file );
|
||||
|
||||
foreach ( (array) $filelist as $filename => $filemeta ) {
|
||||
$this->chmod( $file . '/' . $filename, $mode, $recursive );
|
||||
}
|
||||
@@ -297,6 +308,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
*/
|
||||
public function owner( $file ) {
|
||||
$dir = $this->dirlist( $file );
|
||||
|
||||
return $dir[ $file ]['owner'];
|
||||
}
|
||||
|
||||
@@ -310,6 +322,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
*/
|
||||
public function getchmod( $file ) {
|
||||
$dir = $this->dirlist( $file );
|
||||
|
||||
return $dir[ $file ]['permsn'];
|
||||
}
|
||||
|
||||
@@ -323,6 +336,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
*/
|
||||
public function group( $file ) {
|
||||
$dir = $this->dirlist( $file );
|
||||
|
||||
return $dir[ $file ]['group'];
|
||||
}
|
||||
|
||||
@@ -345,6 +359,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
}
|
||||
|
||||
$content = $this->get_contents( $source );
|
||||
|
||||
if ( false === $content ) {
|
||||
return false;
|
||||
}
|
||||
@@ -383,9 +398,11 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
if ( empty( $file ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( 'f' === $type || $this->is_file( $file ) ) {
|
||||
return $this->ftp->delete( $file );
|
||||
}
|
||||
|
||||
if ( ! $recursive ) {
|
||||
return $this->ftp->rmdir( $file );
|
||||
}
|
||||
@@ -424,9 +441,11 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
if ( $this->is_dir( $file ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( $this->exists( $file ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -440,10 +459,12 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
*/
|
||||
public function is_dir( $path ) {
|
||||
$cwd = $this->cwd();
|
||||
|
||||
if ( $this->chdir( $path ) ) {
|
||||
$this->chdir( $cwd );
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -541,6 +562,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
*/
|
||||
public function mkdir( $path, $chmod = false, $chown = false, $chgrp = false ) {
|
||||
$path = untrailingslashit( $path );
|
||||
|
||||
if ( empty( $path ) ) {
|
||||
return false;
|
||||
}
|
||||
@@ -548,10 +570,13 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
if ( ! $this->ftp->mkdir( $path ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! $chmod ) {
|
||||
$chmod = FS_CHMOD_DIR;
|
||||
}
|
||||
|
||||
$this->chmod( $path, $chmod );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -605,6 +630,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
mbstring_binary_safe_encoding();
|
||||
|
||||
$list = $this->ftp->dirlist( $path );
|
||||
|
||||
if ( empty( $list ) && ! $this->exists( $path ) ) {
|
||||
|
||||
reset_mbstring_encoding();
|
||||
@@ -613,6 +639,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
}
|
||||
|
||||
$ret = array();
|
||||
|
||||
foreach ( $list as $struc ) {
|
||||
|
||||
if ( '.' === $struc['name'] || '..' === $struc['name'] ) {
|
||||
|
||||
Reference in New Issue
Block a user