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

Props: costdev, afragen, mukesh27.
Fixes: #57516.
Built from https://develop.svn.wordpress.org/trunk@55354


git-svn-id: http://core.svn.wordpress.org/trunk@54887 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2023-02-16 22:13:28 +00:00
parent c54e29fd68
commit e3d1a1291f
5 changed files with 25 additions and 20 deletions

View File

@ -629,7 +629,8 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
return false;
}
$ret = array();
$path = trailingslashit( $path );
$ret = array();
while ( false !== ( $entry = $dir->read() ) ) {
$struc = array();
@ -647,20 +648,20 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
continue;
}
$struc['perms'] = $this->gethchmod( $path . '/' . $entry );
$struc['perms'] = $this->gethchmod( $path . $entry );
$struc['permsn'] = $this->getnumchmodfromh( $struc['perms'] );
$struc['number'] = false;
$struc['owner'] = $this->owner( $path . '/' . $entry );
$struc['group'] = $this->group( $path . '/' . $entry );
$struc['size'] = $this->size( $path . '/' . $entry );
$struc['lastmodunix'] = $this->mtime( $path . '/' . $entry );
$struc['owner'] = $this->owner( $path . $entry );
$struc['group'] = $this->group( $path . $entry );
$struc['size'] = $this->size( $path . $entry );
$struc['lastmodunix'] = $this->mtime( $path . $entry );
$struc['lastmod'] = gmdate( 'M j', $struc['lastmodunix'] );
$struc['time'] = gmdate( 'h:i:s', $struc['lastmodunix'] );
$struc['type'] = $this->is_dir( $path . '/' . $entry ) ? 'd' : 'f';
$struc['type'] = $this->is_dir( $path . $entry ) ? 'd' : 'f';
if ( 'd' === $struc['type'] ) {
if ( $recursive ) {
$struc['files'] = $this->dirlist( $path . '/' . $struc['name'], $include_hidden, $recursive );
$struc['files'] = $this->dirlist( $path . $struc['name'], $include_hidden, $recursive );
} else {
$struc['files'] = array();
}

View File

@ -761,12 +761,13 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
$dirlist[ $entry['name'] ] = $entry;
}
$ret = array();
$path = trailingslashit( $path );
$ret = array();
foreach ( (array) $dirlist as $struc ) {
if ( 'd' === $struc['type'] ) {
if ( $recursive ) {
$struc['files'] = $this->dirlist( $path . '/' . $struc['name'], $include_hidden, $recursive );
$struc['files'] = $this->dirlist( $path . $struc['name'], $include_hidden, $recursive );
} else {
$struc['files'] = array();
}

View File

@ -645,7 +645,8 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
return false;
}
$ret = array();
$path = trailingslashit( $path );
$ret = array();
foreach ( $list as $struc ) {
@ -663,7 +664,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
if ( 'd' === $struc['type'] ) {
if ( $recursive ) {
$struc['files'] = $this->dirlist( $path . '/' . $struc['name'], $include_hidden, $recursive );
$struc['files'] = $this->dirlist( $path . $struc['name'], $include_hidden, $recursive );
} else {
$struc['files'] = array();
}

View File

@ -774,6 +774,8 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
return false;
}
$path = trailingslashit( $path );
while ( false !== ( $entry = $dir->read() ) ) {
$struc = array();
$struc['name'] = $entry;
@ -790,20 +792,20 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
continue;
}
$struc['perms'] = $this->gethchmod( $path . '/' . $entry );
$struc['perms'] = $this->gethchmod( $path . $entry );
$struc['permsn'] = $this->getnumchmodfromh( $struc['perms'] );
$struc['number'] = false;
$struc['owner'] = $this->owner( $path . '/' . $entry );
$struc['group'] = $this->group( $path . '/' . $entry );
$struc['size'] = $this->size( $path . '/' . $entry );
$struc['lastmodunix'] = $this->mtime( $path . '/' . $entry );
$struc['owner'] = $this->owner( $path . $entry );
$struc['group'] = $this->group( $path . $entry );
$struc['size'] = $this->size( $path . $entry );
$struc['lastmodunix'] = $this->mtime( $path . $entry );
$struc['lastmod'] = gmdate( 'M j', $struc['lastmodunix'] );
$struc['time'] = gmdate( 'h:i:s', $struc['lastmodunix'] );
$struc['type'] = $this->is_dir( $path . '/' . $entry ) ? 'd' : 'f';
$struc['type'] = $this->is_dir( $path . $entry ) ? 'd' : 'f';
if ( 'd' === $struc['type'] ) {
if ( $recursive ) {
$struc['files'] = $this->dirlist( $path . '/' . $struc['name'], $include_hidden, $recursive );
$struc['files'] = $this->dirlist( $path . $struc['name'], $include_hidden, $recursive );
} else {
$struc['files'] = array();
}

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.2-beta2-55353';
$wp_version = '6.2-beta2-55354';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.