Make WordPress Core


Ignore:
Timestamp:
06/19/2020 10:34:26 AM (5 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-ftpsockets.php

    r47808 r48089  
    3737            return;
    3838        }
     39
    3940        $this->ftp = new ftp();
    4041
     
    8889                )
    8990            );
     91
    9092            return false;
    9193        }
     
    100102                )
    101103            );
     104
    102105            return false;
    103106        }
     
    112115                )
    113116            );
     117
    114118            return false;
    115119        }
     
    118122        $this->ftp->Passive( true );
    119123        $this->ftp->setTimeout( FS_TIMEOUT );
     124
    120125        return true;
    121126    }
     
    135140        }
    136141
    137         $temp = wp_tempnam( $file );
    138 
    139         $temphandle = fopen( $temp, 'w+' );
     142        $tempfile  = wp_tempnam( $file );
     143        $temphandle = fopen( $tempfile, 'w+' );
     144
    140145        if ( ! $temphandle ) {
    141             unlink( $temp );
     146            unlink( $tempfile );
    142147            return false;
    143148        }
     
    147152        if ( ! $this->ftp->fget( $temphandle, $file ) ) {
    148153            fclose( $temphandle );
    149             unlink( $temp );
     154            unlink( $tempfile );
    150155
    151156            reset_mbstring_encoding();
     
    164169
    165170        fclose( $temphandle );
    166         unlink( $temp );
     171        unlink( $tempfile );
     172
    167173        return $contents;
    168174    }
     
    192198     */
    193199    public function put_contents( $file, $contents, $mode = false ) {
    194         $temp       = wp_tempnam( $file );
    195         $temphandle = @fopen( $temp, 'w+' );
     200        $tempfile   = wp_tempnam( $file );
     201        $temphandle = @fopen( $tempfile, 'w+' );
     202
    196203        if ( ! $temphandle ) {
    197             unlink( $temp );
     204            unlink( $tempfile );
    198205            return false;
    199206        }
     
    203210
    204211        $bytes_written = fwrite( $temphandle, $contents );
     212
    205213        if ( false === $bytes_written || strlen( $contents ) != $bytes_written ) {
    206214            fclose( $temphandle );
    207             unlink( $temp );
     215            unlink( $tempfile );
    208216
    209217            reset_mbstring_encoding();
     
    219227
    220228        fclose( $temphandle );
    221         unlink( $temp );
     229        unlink( $tempfile );
    222230
    223231        $this->chmod( $file, $mode );
     
    235243    public function cwd() {
    236244        $cwd = $this->ftp->pwd();
     245
    237246        if ( $cwd ) {
    238247            $cwd = trailingslashit( $cwd );
    239248        }
     249
    240250        return $cwd;
    241251    }
     
    279289        if ( $recursive && $this->is_dir( $file ) ) {
    280290            $filelist = $this->dirlist( $file );
     291
    281292            foreach ( (array) $filelist as $filename => $filemeta ) {
    282293                $this->chmod( $file . '/' . $filename, $mode, $recursive );
     
    298309    public function owner( $file ) {
    299310        $dir = $this->dirlist( $file );
     311
    300312        return $dir[ $file ]['owner'];
    301313    }
     
    311323    public function getchmod( $file ) {
    312324        $dir = $this->dirlist( $file );
     325
    313326        return $dir[ $file ]['permsn'];
    314327    }
     
    324337    public function group( $file ) {
    325338        $dir = $this->dirlist( $file );
     339
    326340        return $dir[ $file ]['group'];
    327341    }
     
    346360
    347361        $content = $this->get_contents( $source );
     362
    348363        if ( false === $content ) {
    349364            return false;
     
    384399            return false;
    385400        }
     401
    386402        if ( 'f' === $type || $this->is_file( $file ) ) {
    387403            return $this->ftp->delete( $file );
    388404        }
     405
    389406        if ( ! $recursive ) {
    390407            return $this->ftp->rmdir( $file );
     
    425442            return false;
    426443        }
     444
    427445        if ( $this->exists( $file ) ) {
    428446            return true;
    429447        }
     448
    430449        return false;
    431450    }
     
    441460    public function is_dir( $path ) {
    442461        $cwd = $this->cwd();
     462
    443463        if ( $this->chdir( $path ) ) {
    444464            $this->chdir( $cwd );
    445465            return true;
    446466        }
     467
    447468        return false;
    448469    }
     
    542563    public function mkdir( $path, $chmod = false, $chown = false, $chgrp = false ) {
    543564        $path = untrailingslashit( $path );
     565
    544566        if ( empty( $path ) ) {
    545567            return false;
     
    549571            return false;
    550572        }
     573
    551574        if ( ! $chmod ) {
    552575            $chmod = FS_CHMOD_DIR;
    553576        }
     577
    554578        $this->chmod( $path, $chmod );
     579
    555580        return true;
    556581    }
     
    606631
    607632        $list = $this->ftp->dirlist( $path );
     633
    608634        if ( empty( $list ) && ! $this->exists( $path ) ) {
    609635
     
    614640
    615641        $ret = array();
     642
    616643        foreach ( $list as $struc ) {
    617644
Note: See TracChangeset for help on using the changeset viewer.