I developed WP Stagecoach using WordPress sites hosted on my own fast servers. That meant I had total control over both the staging server and the live server, and I knew what security limitations I have in place. As soon as I had it working there, I knew it was time to test it out on popular web hosts to see how well it worked there. Every hosting environment is different, and I was certain I would run into problems on some hosts.
The first host that gave me trouble was Media Temple. When I tried to create a staging site for a larger website, it failed with exec errors. At first, I was using Unix utilities via PHP’s exec() function to tar up the filesystem because they are fast. However, not all web hosts actually let you have access to Unix utilities, and while Media Temple does let users access them, they have security in place that would make them not work reliably, so I couldn’t rely on using that. As an alternative, WP Stagecoach can now use PHP to go through all of the files in the website to find the ones we need and tar them up. In other words, instead of using Unix commands to create the staging site, I’m using PHP programs.
However, once I was able to reliably create a tar file with PHP, I would still sometimes get a “500 error” when I was creating a staging site. 500 errors are really unhelpful, but I eventually realized that the problem was that the page was timing out. Media Temple has their timeout set to 40 seconds, so if a PHP page doesn’t finish what it’s trying to do in 40 seconds, it is just forcibly stopped. 40 seconds isn’t always long enough to create the staging site, so the whole process was just stopping on larger sites.
So work around this, I had to make some pretty major changes. The biggest change was that I rewrote the staging site creation method so it was broken up into a number of shorter steps to avoid timing out. This let WP Stagecoach do everything it needed in short bursts of work, and thus avoiding Media Temple’s short timeout periods.
This was a major step forward, and while it is still ugly, it is working, and making it prettier will hopefully be a lot easier than making it work!