[wp-trac] [WordPress Trac] #48689: PHP warnings after updating to WP 5.3: ftp_nlist() and ftp_pwd() expect missing parameters

WordPress Trac noreply at wordpress.org
Mon Dec 6 22:47:37 UTC 2021


#48689: PHP warnings after updating to WP 5.3: ftp_nlist() and ftp_pwd() expect
missing parameters
------------------------------+------------------------------
 Reporter:  Hinjiriyo         |       Owner:  adamsilverstein
     Type:  defect (bug)      |      Status:  assigned
 Priority:  normal            |   Milestone:
Component:  Filesystem API    |     Version:  5.3
 Severity:  minor             |  Resolution:
 Keywords:  needs-patch php8  |     Focuses:
------------------------------+------------------------------

Comment (by adamsilverstein):

 The issue arrises because we pass the file link to several ftp functions
 without first validating it. In certain conditions (for example, when
 WordPress lacks the correct file permissions), the file link is null.

 Passing null to `ftp_pwd`, `ftp_chdir` and `ftp_nlist` throws a warning in
 PHP 7.4 and a fatal in PHP 8+. to avoid this I've added some checks to the
 ftpext functions that were throwing the errors for me. After this patch I
 can load the Site Health page with PHP 8.

 The patch is a POC:
 * not sure this is the best way to fix the issue, didn't look for
 potential issues with other related classes (eg.
 `WP_Filesystem_ftpsockets`)
 * needs tests that validate whatever fix we choose.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/48689#comment:20>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list