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-direct.php

    r48031 r48089  
    6565        public function put_contents( $file, $contents, $mode = false ) {
    6666                $fp = @fopen( $file, 'wb' );
     67
    6768                if ( ! $fp ) {
    6869                        return false;
    … …  
    126127                        return false;
    127128                }
     129
    128130                if ( ! $recursive ) {
    129131                        return chgrp( $file, $group );
    130132                }
     133
    131134                if ( ! $this->is_dir( $file ) ) {
    132135                        return chgrp( $file, $group );
    133136                }
     137
    134138                // Is a directory, and we want recursive.
    135139                $file     = trailingslashit( $file );
    136140                $filelist = $this->dirlist( $file );
     141
    137142                foreach ( $filelist as $filename ) {
    138143                        $this->chgrp( $file . $filename, $group, $recursive );
    … …  
    168173                        return chmod( $file, $mode );
    169174                }
     175
    170176                // Is a directory, and we want recursive.
    171177                $file     = trailingslashit( $file );
    172178                $filelist = $this->dirlist( $file );
     179
    173180                foreach ( (array) $filelist as $filename => $filemeta ) {
    174181                        $this->chmod( $file . $filename, $mode, $recursive );
    … …  
    193200                        return false;
    194201                }
     202
    195203                if ( ! $recursive ) {
    196204                        return chown( $file, $owner );
    197205                }
     206
    198207                if ( ! $this->is_dir( $file ) ) {
    199208                        return chown( $file, $owner );
    200209                }
     210
    201211                // Is a directory, and we want recursive.
    202212                $filelist = $this->dirlist( $file );
     213
    203214                foreach ( $filelist as $filename ) {
    204215                        $this->chown( $file . '/' . $filename, $owner, $recursive );
    205216                }
     217
    206218                return true;
    207219        }
    … …  
    217229        public function owner( $file ) {
    218230                $owneruid = @fileowner( $file );
     231
    219232                if ( ! $owneruid ) {
    220233                        return false;
    221234                }
     235
    222236                if ( ! function_exists( 'posix_getpwuid' ) ) {
    223237                        return $owneruid;
    224238                }
     239
    225240                $ownerarray = posix_getpwuid( $owneruid );
     241
    226242                if ( ! $ownerarray ) {
    227243                        return false;
    228244                }
     245
    229246                return $ownerarray['name'];
    230247        }
    … …  
    254271        public function group( $file ) {
    255272                $gid = @filegroup( $file );
     273
    256274                if ( ! $gid ) {
    257275                        return false;
    258276                }
     277
    259278                if ( ! function_exists( 'posix_getgrgid' ) ) {
    260279                        return $gid;
    261280                }
     281
    262282                $grouparray = posix_getgrgid( $gid );
     283
    263284                if ( ! $grouparray ) {
    264285                        return false;
    265286                }
     287
    266288                return $grouparray['name'];
    267289        }
    … …  
    286308
    287309                $rtval = copy( $source, $destination );
     310
    288311                if ( $mode ) {
    289312                        $this->chmod( $destination, $mode );
    290313                }
     314
    291315                return $rtval;
    292316        }
    … …  
    315339                if ( $this->copy( $source, $destination, $overwrite ) && $this->exists( $destination ) ) {
    316340                        $this->delete( $source );
     341
    317342                        return true;
    318343                } else {
    … …  
    338363                        return false;
    339364                }
     365
    340366                $file = str_replace( '\\', '/', $file ); // For Win32, occasional problems deleting files otherwise.
    341367
    … …  
    343369                        return @unlink( $file );
    344370                }
     371
    345372                if ( ! $recursive && $this->is_dir( $file ) ) {
    346373                        return @rmdir( $file );
    … …  
    352379
    353380                $retval = true;
     381
    354382                if ( is_array( $filelist ) ) {
    355383                        foreach ( $filelist as $filename => $fileinfo ) {
    … …  
    481509                        $time = time();
    482510                }
     511
    483512                if ( 0 == $atime ) {
    484513                        $atime = time();
    485514                }
     515
    486516                return touch( $file, $time, $atime );
    487517        }
    … …  
    504534                // Safe mode fails with a trailing slash under certain PHP versions.
    505535                $path = untrailingslashit( $path );
     536
    506537                if ( empty( $path ) ) {
    507538                        return false;
    … …  
    515546                        return false;
    516547                }
     548
    517549                $this->chmod( $path, $chmod );
     550
    518551                if ( $chown ) {
    519552                        $this->chown( $path, $chown );
    520553                }
     554
    521555                if ( $chgrp ) {
    522556                        $this->chgrp( $path, $chgrp );
    523557                }
     558
    524559                return true;
    525560        }
    … …  
    577612
    578613                $dir = dir( $path );
     614
    579615                if ( ! $dir ) {
    580616                        return false;
    … …  
    620656                        $ret[ $struc['name'] ] = $struc;
    621657                }
     658
    622659                $dir->close();
    623660                unset( $dir );
     661
    624662                return $ret;
    625663        }
Note: See TracChangeset for help on using the changeset viewer.