Make WordPress Core


Ignore:
Timestamp:
02/16/2023 10:11:32 PM (2 years ago)
Author:
azaozz
Message:

Filesystem API: Use trailingslashit( $path ) instead of $path . '/'. Fixes a warning when $path already ends with a slash.

Props: costdev, afragen, mukesh27.
Fixes: #57516.

File:
1 edited

Legend:

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

    r55205 r55354  
    775775        }
    776776
     777        $path = trailingslashit( $path );
     778
    777779        while ( false !== ( $entry = $dir->read() ) ) {
    778780            $struc         = array();
     
    791793            }
    792794
    793             $struc['perms']       = $this->gethchmod( $path . '/' . $entry );
     795            $struc['perms']       = $this->gethchmod( $path . $entry );
    794796            $struc['permsn']      = $this->getnumchmodfromh( $struc['perms'] );
    795797            $struc['number']      = false;
    796             $struc['owner']       = $this->owner( $path . '/' . $entry );
    797             $struc['group']       = $this->group( $path . '/' . $entry );
    798             $struc['size']        = $this->size( $path . '/' . $entry );
    799             $struc['lastmodunix'] = $this->mtime( $path . '/' . $entry );
     798            $struc['owner']       = $this->owner( $path . $entry );
     799            $struc['group']       = $this->group( $path . $entry );
     800            $struc['size']        = $this->size( $path . $entry );
     801            $struc['lastmodunix'] = $this->mtime( $path . $entry );
    800802            $struc['lastmod']     = gmdate( 'M j', $struc['lastmodunix'] );
    801803            $struc['time']        = gmdate( 'h:i:s', $struc['lastmodunix'] );
    802             $struc['type']        = $this->is_dir( $path . '/' . $entry ) ? 'd' : 'f';
     804            $struc['type']        = $this->is_dir( $path . $entry ) ? 'd' : 'f';
    803805
    804806            if ( 'd' === $struc['type'] ) {
    805807                if ( $recursive ) {
    806                     $struc['files'] = $this->dirlist( $path . '/' . $struc['name'], $include_hidden, $recursive );
     808                    $struc['files'] = $this->dirlist( $path . $struc['name'], $include_hidden, $recursive );
    807809                } else {
    808810                    $struc['files'] = array();
Note: See TracChangeset for help on using the changeset viewer.