TL;DR: If you use the php-ssh2 extension for your WordPress core / theme / plugin updates, you might want to wait a little longer before upgrading to PHP 7.
Last month, one of my VPS servers suffered a catastrophic disk failure, taking down several personal websites that my wife and I manage. All of our WordPress content is on a separate database server, so the main content is still intact. I’ve also been able to extract a few things from a raw image of the damaged drive. But there were some things (site-specific plugins, child-themes, media content, utility scripts, my email archives) which are likely gone for good, or that will at least be painful to put back into place (uploaded images, etc.).
There’s not much use crying over spilt milk, though, so I at least saw this as an opportunity to freshen up and improve upon my previous server configuration. In its previous incarnation, I had been running Apache workers, and PHP-FPM (PHP 5.6.x). But I also had some web experiments in Nodejs, which I had to run on a non-standard port, so as to not conflict with Apache. Since I was starting from scratch anyways, I’ve decided to put HAProxy in front of everything, so that I can internally run multiple web servers, and just proxy to them transparently. And while I was at it, I’ve been hearing a lot of good things about the speed improvements in PHP 7, so I figured I’d upgrade that, as well.
I won’t go into the nitty-gritty details of my install (especially since I’m not finished yet), but I did want to let others know about a problem I’ve run into: There is a new development build of the php-ssh2 extension for PHP 7, but it is not quite complete yet. Many things do work, but unfortunately, all of the functions which rely on the ability to use the
stat() call are broken at this time. This includes other file-checking functions such as
file_exists(). In WordPress, if you are using the SSH2 filesystem class (rather than FTP or FTPS), this will prevent you from using the built-in plugin and theme installers, or any of the automatic upgrade functionality.
After digging around in the php-ssh2 extension source code for a while and comparing to a previous version, I was unable to find the problem myself. My C programming is too rusty, and I just don’t have the time to start learning PHP and libssh2 internals from scratch. But, I did file a bug on the PHP Bugtracker, and the author of the PHP 7 port of the php-ssh2 extension has said that he is working on a fix. So keep an out out for an update on that.
Just as a side-note, using fstat() on a filehandle opened on an ssh2.sftp file resource, or using the ssh2_sftp_stat() call do work. But that doesn’t help with the is_dir() and is_file() calls which are failing in the class-wp-filesystem-ssh2.php code. Those functions rely on the PHP internal ssh2.sftp stream wrappers.
Postscript: I know plenty of people will say, “You should have had backups!” or even, “Your VPS host must suck for not having backups!”. The former is absolutely true — I should have done better at backing up some of the things that I did not have backups for. The VPS host is not really to blame. I had gotten a disk size upgrade, and I actually had an opportunity to request a snapshot of my system before I ran the upgrade process to extend my disk. But because I had run it successfully on another server without incident, I got careless. And after the upgrade, the system seemed to run fine for about three weeks before any problems surfaced.
Pingback: Dougal Campbell: WordPress, PHP7, and Updates via php-ssh2 | WordPress Planet