Make WordPress Core


Ignore:
Timestamp:
06/19/2020 10:34:26 AM (6 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-filesystem-ssh2.php

    r48031 r48089  
    133133                )
    134134            );
     135
    135136            return false;
    136137        }
     
    146147                    )
    147148                );
     149
    148150                return false;
    149151            }
     
    158160                    )
    159161                );
     162
    160163                return false;
    161164            }
     
    163166
    164167        $this->sftp_link = ssh2_sftp( $this->link );
     168
    165169        if ( ! $this->sftp_link ) {
    166170            $this->errors->add(
     
    172176                )
    173177            );
     178
    174179            return false;
    175180        }
     
    195200            $path = '/./';
    196201        }
     202
    197203        return 'ssh2.sftp://' . $this->sftp_link . '/' . ltrim( $path, '/' );
    198204    }
     
    212218
    213219        $stream = ssh2_exec( $this->link, $command );
     220
    214221        if ( ! $stream ) {
    215222            $this->errors->add(
     
    233240            }
    234241        }
     242
    235243        return false;
    236244    }
     
    293301    public function cwd() {
    294302        $cwd = ssh2_sftp_realpath( $this->sftp_link, '.' );
     303
    295304        if ( $cwd ) {
    296305            $cwd = trailingslashit( trim( $cwd ) );
    297306        }
     307
    298308        return $cwd;
    299309    }
     
    326336            return false;
    327337        }
     338
    328339        if ( ! $recursive || ! $this->is_dir( $file ) ) {
    329340            return $this->run_command( sprintf( 'chgrp %s %s', escapeshellarg( $group ), escapeshellarg( $file ) ), true );
    330341        }
     342
    331343        return $this->run_command( sprintf( 'chgrp -R %s %s', escapeshellarg( $group ), escapeshellarg( $file ) ), true );
    332344    }
     
    362374            return $this->run_command( sprintf( 'chmod %o %s', $mode, escapeshellarg( $file ) ), true );
    363375        }
     376
    364377        return $this->run_command( sprintf( 'chmod -R %o %s', $mode, escapeshellarg( $file ) ), true );
    365378    }
     
    380393            return false;
    381394        }
     395
    382396        if ( ! $recursive || ! $this->is_dir( $file ) ) {
    383397            return $this->run_command( sprintf( 'chown %s %s', escapeshellarg( $owner ), escapeshellarg( $file ) ), true );
    384398        }
     399
    385400        return $this->run_command( sprintf( 'chown -R %s %s', escapeshellarg( $owner ), escapeshellarg( $file ) ), true );
    386401    }
     
    396411    public function owner( $file ) {
    397412        $owneruid = @fileowner( $this->sftp_path( $file ) );
     413
    398414        if ( ! $owneruid ) {
    399415            return false;
    400416        }
     417
    401418        if ( ! function_exists( 'posix_getpwuid' ) ) {
    402419            return $owneruid;
    403420        }
     421
    404422        $ownerarray = posix_getpwuid( $owneruid );
     423
    405424        if ( ! $ownerarray ) {
    406425            return false;
    407426        }
     427
    408428        return $ownerarray['name'];
    409429    }
     
    431451    public function group( $file ) {
    432452        $gid = @filegroup( $this->sftp_path( $file ) );
     453
    433454        if ( ! $gid ) {
    434455            return false;
    435456        }
     457
    436458        if ( ! function_exists( 'posix_getgrgid' ) ) {
    437459            return $gid;
    438460        }
     461
    439462        $grouparray = posix_getgrgid( $gid );
     463
    440464        if ( ! $grouparray ) {
    441465            return false;
    442466        }
     467
    443468        return $grouparray['name'];
    444469    }
     
    461486            return false;
    462487        }
     488
    463489        $content = $this->get_contents( $source );
     490
    464491        if ( false === $content ) {
    465492            return false;
    466493        }
     494
    467495        return $this->put_contents( $destination, $content, $mode );
    468496    }
     
    509537            return ssh2_sftp_unlink( $this->sftp_link, $file );
    510538        }
     539
    511540        if ( ! $recursive ) {
    512541            return ssh2_sftp_rmdir( $this->sftp_link, $file );
    513542        }
     543
    514544        $filelist = $this->dirlist( $file );
     545
    515546        if ( is_array( $filelist ) ) {
    516547            foreach ( $filelist as $filename => $fileinfo ) {
     
    518549            }
    519550        }
     551
    520552        return ssh2_sftp_rmdir( $this->sftp_link, $file );
    521553    }
     
    651683    public function mkdir( $path, $chmod = false, $chown = false, $chgrp = false ) {
    652684        $path = untrailingslashit( $path );
     685
    653686        if ( empty( $path ) ) {
    654687            return false;
     
    658691            $chmod = FS_CHMOD_DIR;
    659692        }
     693
    660694        if ( ! ssh2_sftp_mkdir( $this->sftp_link, $path, $chmod, true ) ) {
    661695            return false;
    662696        }
     697
    663698        if ( $chown ) {
    664699            $this->chown( $path, $chown );
    665700        }
     701
    666702        if ( $chgrp ) {
    667703            $this->chgrp( $path, $chgrp );
    668704        }
     705
    669706        return true;
    670707    }
     
    765802            $ret[ $struc['name'] ] = $struc;
    766803        }
     804
    767805        $dir->close();
    768806        unset( $dir );
     807
    769808        return $ret;
    770809    }
Note: See TracChangeset for help on using the changeset viewer.