WordPress.org

Make WordPress Core

Opened 4 months ago

Closed 4 months 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
Milestone: 5.5 Priority: normal
Severity: normal Version: 5.4.2
Component: Filesystem API Keywords: needs-patch
Focuses: Cc:

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
4 months ago

PHP version 7.4.x

#2 @SergeyBiryukov
4 months ago

  • Component changed from Upgrade/Install to Filesystem API
  • Milestone changed from Awaiting Review to 5.5

#3 @SergeyBiryukov
4 months 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
4 months ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

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.