After upgrading Debian Buster to Bullseye, WordPress sites no longer updating

It took me a while to figure out exactly what was going on but it’s actually a problem with WordPress. Bullseye installs version 1.0.49 of PureFTPd where in Buster v1.0.47 was installed. According to PureFTPd’s changelog here, globbing was removed from the NLST command in v1.0.48 (which makes sense since it’s actually not allowed according to the RFC).

The WordPress developers are aware of the problem and have patched the exists() function. The patch is available here; applying it is one of two ways to upgrade WordPress if your using PureFTPd version 1.0.48 or up and are stuck with upgrading through FTP.

You can also replace the function yourself in /wp-admin/includes/class-wp-filesystem-ftpext.php (or /wp-admin/includes/class-wp-filesystem-ftpsockets.php if you are using FTPSockets) with the following (which is actually my own implementation of the function):


        public function exists( $file ) {
          $retval = false;

          $list = ftp_nlist( $this->link, $file );
          if( ! empty( $list ) ) {
            // if ftp_nlist returns *something*, the file or directory exists, on any FTP server
            $retval = true;
          } else {
            // if ftp_nlist returns nothing, either the file/dir doesn't exist or it's a file and
            // the FTP server's NLST command doesn't support globbing (i.e. Pure-FTPD > v1.0.47)
            // Check if it'a file
            if( ftp_size( $this->link, $file ) >= 0 ) {
              $retval = true;
            }
          }
          return $retval;

        }

WordPress 6.0 will have the new function by default.