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:
parent
73669965a6
commit
d32ec3352b
@ -223,6 +223,9 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
|||||||
return $owneruid;
|
return $owneruid;
|
||||||
}
|
}
|
||||||
$ownerarray = posix_getpwuid( $owneruid );
|
$ownerarray = posix_getpwuid( $owneruid );
|
||||||
|
if ( ! $ownerarray ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return $ownerarray['name'];
|
return $ownerarray['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,6 +260,9 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
|||||||
return $gid;
|
return $gid;
|
||||||
}
|
}
|
||||||
$grouparray = posix_getgrgid( $gid );
|
$grouparray = posix_getgrgid( $gid );
|
||||||
|
if ( ! $grouparray ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return $grouparray['name'];
|
return $grouparray['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -402,6 +402,9 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
|||||||
return $owneruid;
|
return $owneruid;
|
||||||
}
|
}
|
||||||
$ownerarray = posix_getpwuid( $owneruid );
|
$ownerarray = posix_getpwuid( $owneruid );
|
||||||
|
if ( ! $ownerarray ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return $ownerarray['name'];
|
return $ownerarray['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -434,6 +437,9 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
|||||||
return $gid;
|
return $gid;
|
||||||
}
|
}
|
||||||
$grouparray = posix_getgrgid( $gid );
|
$grouparray = posix_getgrgid( $gid );
|
||||||
|
if ( ! $grouparray ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return $grouparray['name'];
|
return $grouparray['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user