From 4cc11cdbdda35a64bcfe5d068581d868120251c2 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Fri, 12 Jun 2020 12:35:09 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@48031 git-svn-id: http://core.svn.wordpress.org/trunk@47798 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/class-wp-filesystem-direct.php | 6 ++++++ wp-admin/includes/class-wp-filesystem-ssh2.php | 6 ++++++ wp-includes/version.php | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/wp-admin/includes/class-wp-filesystem-direct.php b/wp-admin/includes/class-wp-filesystem-direct.php index 7551e3d273..17ccad8d5d 100644 --- a/wp-admin/includes/class-wp-filesystem-direct.php +++ b/wp-admin/includes/class-wp-filesystem-direct.php @@ -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']; } diff --git a/wp-admin/includes/class-wp-filesystem-ssh2.php b/wp-admin/includes/class-wp-filesystem-ssh2.php index c099259e1f..94853a650b 100644 --- a/wp-admin/includes/class-wp-filesystem-ssh2.php +++ b/wp-admin/includes/class-wp-filesystem-ssh2.php @@ -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']; } diff --git a/wp-includes/version.php b/wp-includes/version.php index 53130e01d3..a2528c1aaa 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.5-alpha-48028'; +$wp_version = '5.5-alpha-48031'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.