alistairphillips.com

I’m : a web and mobile developer based in the Manning Valley, Australia.


When you cannot upgrade PHP

Guess that the title says it all. I spent the weekend developing an XML-RPC interface to allow one of our clients to access (well insert) records into one of the projects that we are busy developing.

The initial development was done on my laptop and everything was fine. Come Monday morning I transferred it over to the local server at work (only accessible via the LAN or VPN), changed a value or two due to database differences and everything was fine.

So I fired up Smart FTP and uploaded the files and then tried to run the test. Unfortunately instead of getting "the call worked" I was greeted with loads of errors. After struggling for 15 minutes I eventually found out that we were running a version of PHP that did not support the function that the XML-RPC script required.

Now I'm not one to go and upgrade things on the RaQ due to issues that might occur (i.e. bringing down the entire server!). So off I went to Bryn only to discover that he actually had the same issue before.

A newer version of PHP had been installed into an alternate location which would work - but how would I be able to get Apache to work with it without breaking everything?

Turns out all that I had to do was create a new PHP page that offered a "virtual" XML-RPC interface that the client would post. In this page I wrote the HTTP_RAW_POST_DATA to a database and then used the passthru() script to call the newer PHP binary and make it run the real XML-RPC script.

When calling the new script I passed it the row id from the insert so that it could retrieve that POST data. Only required a couple of extra lines into the server script so that it could pull the data out of the database and stick it into the variable that it was expecting.

And voila it was all working!

Might not be pretty but it does the job.