Filesystem API: Avoid a PHP notice in WP_Filesystem_Direct::owner() and ::group() methods and their WP_Filesystem_SSH2 counterparts.

Although not officially documented in the PHP manual, `posix_getpwuid()` and `posix_getgrgid()` can return `false` in some circumstances.

Props logig.
Fixes #50373.

git-svn-id: https://develop.svn.wordpress.org/trunk@48031 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2020-06-12 12:33:12 +00:00
parent 73669965a6
commit d32ec3352b
2 changed files with 12 additions and 0 deletions

View File

@ -223,6 +223,9 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
return $owneruid;
}
$ownerarray = posix_getpwuid( $owneruid );
if ( ! $ownerarray ) {
return false;
}
return $ownerarray['name'];
}
@ -257,6 +260,9 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
return $gid;
}
$grouparray = posix_getgrgid( $gid );
if ( ! $grouparray ) {
return false;
}
return $grouparray['name'];
}

View File

@ -402,6 +402,9 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
return $owneruid;
}
$ownerarray = posix_getpwuid( $owneruid );
if ( ! $ownerarray ) {
return false;
}
return $ownerarray['name'];
}
@ -434,6 +437,9 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
return $gid;
}
$grouparray = posix_getgrgid( $gid );
if ( ! $grouparray ) {
return false;
}
return $grouparray['name'];
}