Make WordPress Core

Changeset 48031


Ignore:
Timestamp:
06/12/2020 12:33:12 PM (5 years ago)
Author:
SergeyBiryukov
Message:

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.

Location:
trunk/src/wp-admin/includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-filesystem-direct.php

    r47808 r48031  
    224224        }
    225225        $ownerarray = posix_getpwuid( $owneruid );
     226        if ( ! $ownerarray ) {
     227            return false;
     228        }
    226229        return $ownerarray['name'];
    227230    }
     
    258261        }
    259262        $grouparray = posix_getgrgid( $gid );
     263        if ( ! $grouparray ) {
     264            return false;
     265        }
    260266        return $grouparray['name'];
    261267    }
  • trunk/src/wp-admin/includes/class-wp-filesystem-ssh2.php

    r47808 r48031  
    403403        }
    404404        $ownerarray = posix_getpwuid( $owneruid );
     405        if ( ! $ownerarray ) {
     406            return false;
     407        }
    405408        return $ownerarray['name'];
    406409    }
     
    435438        }
    436439        $grouparray = posix_getgrgid( $gid );
     440        if ( ! $grouparray ) {
     441            return false;
     442        }
    437443        return $grouparray['name'];
    438444    }
Note: See TracChangeset for help on using the changeset viewer.