Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#50373 closed defect (bug) (fixed)

Notice: Trying to access array offset on value of type bool in /wp-admin/includes/class-wp-filesystem-direct.php on line 260

Reported by: logig Owned by: SergeyBiryukov
Priority: normal Milestone: 5.5
Component: Filesystem API Version: 5.4.2
Severity: normal Keywords: needs-patch
Cc: Focuses:

Description

Notice: Trying to access array offset on value of type bool in /wp-admin/includes/class-wp-filesystem-direct.php on line 260
Notice: Trying to access array offset on value of type bool in /wp-admin/includes/class-wp-filesystem-direct.php on line 260
Notice: Trying to access array offset on value of type bool in /wp-admin/includes/class-wp-filesystem-direct.php on line 260
Notice: Trying to access array offset on value of type bool in /wp-admin/includes/class-wp-filesystem-direct.php on line 260
Notice: Trying to access array offset on value of type bool in /wp-admin/includes/class-wp-filesystem-direct.php on line 260

There are many Notices when updating.

Change History (4)

#1 @logig
6 years ago

PHP version 7.4.x

#2 @SergeyBiryukov
6 years ago

  • Component Upgrade/InstallFilesystem API
  • Milestone Awaiting Review5.5

#3 @SergeyBiryukov
6 years ago

Hi there, welcome to WordPress Trac! Thanks for the report.

The PHP manual mentions that fileowner() and filegroup() return false on failure, but doesn't mention the same for posix_getpwuid() or posix_getgrgid() used in the WP_Filesystem_Direct and WP_Filesystem_SSH2 classes.

Apparently they can still return false in some circumstances, per these comments:
https://www.php.net/manual/en/function.posix-getpwuid.php#45994
https://www.php.net/manual/en/function.posix-getgrgid.php#90794

So checking the result seems like a good idea.

#4 @SergeyBiryukov
6 years ago

  • Owner set to SergeyBiryukov
  • Resolutionfixed
  • Status newclosed

In 48031:

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.

Note: See TracTickets for help on using tickets.