Immediately after activating the add_from_server plugin, my WordPress site crashed (the Admin Dashboard only - not the main site itself).
This is probably because I am using PHP 5.4.
I have root access to the Linux shell (running WordPress on AWS), and when I do:
php --version
it says:
PHP 5.4.11-1~precise+1 (cli) (built: Jan 24 2013 15:22:16)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
Let's back up a minute and look at this from a broader perspective: not involving just this plugin, but the larger question of "Why does the PHP community consider it normal to use a plugin to do something which could easily be done through the command line (or through something like PHPMyAdmin?"
Before anyone says "hey it could be dangerous to just add stuff via the command line or via PHPMyAdmin" let us remember: this is what add_from_server purports to do (only more opaquely: using PHP). So we're doing it anyways - just opaquely, via a (possibly outdated) plugin, rather than doing it ourselves transparently, on the command line or via PHPMyAdmin.
It would be nice there were some documentation somewhere simply explaining which records need to be inserted into which MySQL tables in order to for WordPress to "see" a newly uploaded media file - and in which order these insertions should be performed (in case there are any foreign relationships causing dependencies between tables). I imagine this was the information which was used to create the add_from_server plugin. Where is this information?
I realize that many WordPress users can't or don't want to directly access their MySQL tables. On the other hand, I have installed SQLBuddy on my server (since PHPMyAdmin is too "heavy" in my opinion), so I could insert records into MySQL (imitating what add_from_server is attempting to do) - if there were some easy-to-find documentation telling me which records to insert in which tables and in which order. It would be much easier and more stable to do it this way, instead of relying on a plugin which may or may not work depending on which version of PHP I'm using.
This is part of the "Keep It Simple" philosophy: If you want to add a record to MySQL, then use MySQL - don't download a plugin to do it through PHP.
+++
As we know, media is added to a WordPress site in two steps:
(1) The file is uploaded to a certain directory on the server.
(2) WordPress is "informed" of this fact via records being inserted in a couple of MySQL tables.
At some point, it just gets to be counterproductive adding layer upon layer of complexity to our systems - eg, doing the above two steps via a plugin using PHP - when the definition of PHP itself is constantly shifting like quicksand. (As mentioned by SimonSimCity above, evidently the designers of the PHP language recently decided that the language feature known as "reference sign on function call" is a bad programming practice, and they removed this from the language a while ago - but the add_from_server plugin used this language feature, so it crashes in PHP 5.4.)
After trying dozens of CMSs, and after so many bad experiences installing and using PHP (at one point I had to wipe an entire server, due to conflicts between some of the countless components needed to use PHP with a particular web app such as WordPress), I finally resigned myself to using WordPress simply because the large size of the community (making many plugins available) can cancel out some of the shakiness of working in a poorly designed language such as PHP. (There, I said it, so flame away.)
In this sense, due to the sheer number of plugins, WordPress can be considered a "de facto" web application framework itself - at least for CMS web apps, because it is often easier to reach out and grab a WordPress plugin rather than writing the same functionality from scratch yourself. (So at least I'm a realist: I may not like PHP, but I know that I have to use it, simply because everyone else does.)
By the, way, this story has a happy ending.
I had already learned to be paranoid about installing new WordPress plugins - after a previous installation of a WordPress plugin took down my entire site.
So, although the add_from_server plugin is very tiny (I looked at the code), I still decided to be paranoid and I made a backup before installing it. (On Amazon AWS, I created a snapshot.)
I am so glad I did this. After the installation of add_from_server killed my WordPress Admin Dashboard, I simply restored the AWS snapshot, and my site back up and running again in minutes.
This suggests a philosophy going forward, of being conservative and paranoid regarding plugins:
- Conservative: Only install a plugin when absolutely necessary. (Because PHP and WordPress itself change so often, there is no guarantee that the plugin will work with your version of PHP and WordPress. And as I have seen twice, a plugin can take down the entire site.)
- Paranoid: If you do decide you absolutely must install a plugin, then back up your entire website/server before installing any plugin. It would even be better (if you have an additional server available) to test restoring this backup to the new server, before assuming that you really do have a usable backup.
Unfortunately, given the current state of the art in web programming, we have to pracice this sort of "defensive web admin".