I’m not sure when this warning started. I got an existing site to do its hosting and applied the following good practices:
- Updated WordPress – from 5.3 to 5.4.0 (current WP version)
- Updated all plugins – it’s a big list so I won’t add it here
- Changed file permissions and owner – everything owned by my user (not Apache) and only the folder
wp-content
is writable by Apache (with some restrictions inside) -> WordPress Hardening Guide
As a note, the Apache user and group are used both by both Apache and PHP-FPM. We only use the server (VM) for this website, so I don’t have to address security challenges related to process sharing.
With these changes, I started having the following PHP warnings (Yes, I did everything at the same time! Sorry for that):
Warning: ftp_nlist() expects parameter 1 to be resource, null given in /var/www/html/wp-admin/includes/class-wp-filesystem-ftpext.php on line 402
Warning: ftp_pwd() expects parameter 1 to be resource, null given in /var/www/html/wp-admin/includes/class-wp-filesystem-ftpext.php on line 226
Warning: ftp_pwd() expects parameter 1 to be resource, null given in /var/www/html/wp-admin/includes/class-wp-filesystem-ftpext.php on line 226
Warning: ftp_pwd() expects parameter 1 to be resource, null given in /var/www/html/wp-admin/includes/class-wp-filesystem-ftpext.php on line 681
Warning: ftp_nlist() expects parameter 1 to be resource, null given in /var/www/html/wp-admin/includes/class-wp-filesystem-ftpext.php on line 402
Warning: ftp_pwd() expects parameter 1 to be resource, null given in /var/www/html/wp-admin/includes/class-wp-filesystem-ftpext.php on line 226
Warning: ftp_pwd() expects parameter 1 to be resource, null given in /var/www/html/wp-admin/includes/class-wp-filesystem-ftpext.php on line 226
Warning: ftp_pwd() expects parameter 1 to be resource, null given in /var/www/html/wp-admin/includes/class-wp-filesystem-ftpext.php on line 681
Warning: ftp_nlist() expects parameter 1 to be resource, null given in /var/www/html/wp-admin/includes/class-wp-filesystem-ftpext.php on line 402
Warning: ftp_pwd() expects parameter 1 to be resource, null given in /var/www/html/wp-admin/includes/class-wp-filesystem-ftpext.php on line 226
Warning: ftp_pwd() expects parameter 1 to be resource, null given in /var/www/html/wp-admin/includes/class-wp-filesystem-ftpext.php on line 226
Warning: ftp_rmdir() expects parameter 1 to be resource, null given in /var/www/html/wp-admin/includes/class-wp-filesystem-ftpext.php on line 381
Warning: ftp_nlist() expects parameter 1 to be resource, null given in /var/www/html/wp-admin/includes/class-wp-filesystem-ftpext.php on line 402
Warning: ftp_pwd() expects parameter 1 to be resource, null given in /var/www/html/wp-admin/includes/class-wp-filesystem-ftpext.php on line 226
Warning: ftp_pwd() expects parameter 1 to be resource, null given in /var/www/html/wp-admin/includes/class-wp-filesystem-ftpext.php on line 226
Warning: ftp_pwd() expects parameter 1 to be resource, null given in /var/www/html/wp-admin/includes/class-wp-filesystem-ftpext.php on line 681
These warnings appear in the PHP-FPM log file in every call to the server. If I set define( 'WP_DEBUG', true );
they can be found in every page.
Steps to solve
I can stop these warnings doing one of the following:
- Disabling the plugins Swift Framework and Redux Framework.
- Setting the file ownership of the WordPress folder to Apache.
None of these changes is the desired solution. The first breaks the site, and the second creates a security problem.
WordPress bug?
I’ve also found the WordPress issue 48689 that describes the same errors but associated with different plugins. However, the solution (if (!defined('FS_METHOD')) define('FS_METHOD', 'direct');
) doesn’t work in my case. The remaining options are hiding the warnings don’t seem to be a good idea.