mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-04 17:20:07 +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:
@@ -132,6 +132,7 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
||||
$this->options['hostname'] . ':' . $this->options['port']
|
||||
)
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -145,6 +146,7 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
||||
$this->options['username']
|
||||
)
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
@@ -157,11 +159,13 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
||||
$this->options['username']
|
||||
)
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$this->sftp_link = ssh2_sftp( $this->link );
|
||||
|
||||
if ( ! $this->sftp_link ) {
|
||||
$this->errors->add(
|
||||
'connect',
|
||||
@@ -171,6 +175,7 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
||||
$this->options['hostname'] . ':' . $this->options['port']
|
||||
)
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -194,6 +199,7 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
||||
if ( '/' === $path ) {
|
||||
$path = '/./';
|
||||
}
|
||||
|
||||
return 'ssh2.sftp://' . $this->sftp_link . '/' . ltrim( $path, '/' );
|
||||
}
|
||||
|
||||
@@ -211,6 +217,7 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
||||
}
|
||||
|
||||
$stream = ssh2_exec( $this->link, $command );
|
||||
|
||||
if ( ! $stream ) {
|
||||
$this->errors->add(
|
||||
'command',
|
||||
@@ -232,6 +239,7 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -292,9 +300,11 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
||||
*/
|
||||
public function cwd() {
|
||||
$cwd = ssh2_sftp_realpath( $this->sftp_link, '.' );
|
||||
|
||||
if ( $cwd ) {
|
||||
$cwd = trailingslashit( trim( $cwd ) );
|
||||
}
|
||||
|
||||
return $cwd;
|
||||
}
|
||||
|
||||
@@ -325,9 +335,11 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
||||
if ( ! $this->exists( $file ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! $recursive || ! $this->is_dir( $file ) ) {
|
||||
return $this->run_command( sprintf( 'chgrp %s %s', escapeshellarg( $group ), escapeshellarg( $file ) ), true );
|
||||
}
|
||||
|
||||
return $this->run_command( sprintf( 'chgrp -R %s %s', escapeshellarg( $group ), escapeshellarg( $file ) ), true );
|
||||
}
|
||||
|
||||
@@ -361,6 +373,7 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
||||
if ( ! $recursive || ! $this->is_dir( $file ) ) {
|
||||
return $this->run_command( sprintf( 'chmod %o %s', $mode, escapeshellarg( $file ) ), true );
|
||||
}
|
||||
|
||||
return $this->run_command( sprintf( 'chmod -R %o %s', $mode, escapeshellarg( $file ) ), true );
|
||||
}
|
||||
|
||||
@@ -379,9 +392,11 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
||||
if ( ! $this->exists( $file ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! $recursive || ! $this->is_dir( $file ) ) {
|
||||
return $this->run_command( sprintf( 'chown %s %s', escapeshellarg( $owner ), escapeshellarg( $file ) ), true );
|
||||
}
|
||||
|
||||
return $this->run_command( sprintf( 'chown -R %s %s', escapeshellarg( $owner ), escapeshellarg( $file ) ), true );
|
||||
}
|
||||
|
||||
@@ -395,16 +410,21 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
||||
*/
|
||||
public function owner( $file ) {
|
||||
$owneruid = @fileowner( $this->sftp_path( $file ) );
|
||||
|
||||
if ( ! $owneruid ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'posix_getpwuid' ) ) {
|
||||
return $owneruid;
|
||||
}
|
||||
|
||||
$ownerarray = posix_getpwuid( $owneruid );
|
||||
|
||||
if ( ! $ownerarray ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $ownerarray['name'];
|
||||
}
|
||||
|
||||
@@ -430,16 +450,21 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
||||
*/
|
||||
public function group( $file ) {
|
||||
$gid = @filegroup( $this->sftp_path( $file ) );
|
||||
|
||||
if ( ! $gid ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'posix_getgrgid' ) ) {
|
||||
return $gid;
|
||||
}
|
||||
|
||||
$grouparray = posix_getgrgid( $gid );
|
||||
|
||||
if ( ! $grouparray ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $grouparray['name'];
|
||||
}
|
||||
|
||||
@@ -460,10 +485,13 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
||||
if ( ! $overwrite && $this->exists( $destination ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$content = $this->get_contents( $source );
|
||||
|
||||
if ( false === $content ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->put_contents( $destination, $content, $mode );
|
||||
}
|
||||
|
||||
@@ -508,15 +536,19 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
||||
if ( 'f' === $type || $this->is_file( $file ) ) {
|
||||
return ssh2_sftp_unlink( $this->sftp_link, $file );
|
||||
}
|
||||
|
||||
if ( ! $recursive ) {
|
||||
return ssh2_sftp_rmdir( $this->sftp_link, $file );
|
||||
}
|
||||
|
||||
$filelist = $this->dirlist( $file );
|
||||
|
||||
if ( is_array( $filelist ) ) {
|
||||
foreach ( $filelist as $filename => $fileinfo ) {
|
||||
$this->delete( $file . '/' . $filename, $recursive, $fileinfo['type'] );
|
||||
}
|
||||
}
|
||||
|
||||
return ssh2_sftp_rmdir( $this->sftp_link, $file );
|
||||
}
|
||||
|
||||
@@ -650,6 +682,7 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
||||
*/
|
||||
public function mkdir( $path, $chmod = false, $chown = false, $chgrp = false ) {
|
||||
$path = untrailingslashit( $path );
|
||||
|
||||
if ( empty( $path ) ) {
|
||||
return false;
|
||||
}
|
||||
@@ -657,15 +690,19 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
||||
if ( ! $chmod ) {
|
||||
$chmod = FS_CHMOD_DIR;
|
||||
}
|
||||
|
||||
if ( ! ssh2_sftp_mkdir( $this->sftp_link, $path, $chmod, true ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( $chown ) {
|
||||
$this->chown( $path, $chown );
|
||||
}
|
||||
|
||||
if ( $chgrp ) {
|
||||
$this->chgrp( $path, $chgrp );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -764,8 +801,10 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
||||
|
||||
$ret[ $struc['name'] ] = $struc;
|
||||
}
|
||||
|
||||
$dir->close();
|
||||
unset( $dir );
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user