...And Now It Doesn't Work!

Whole bunch of computery crap ahead...

The company that hosts this website and the website for my side business moved my particular server to a new machine, and in the process, upgraded the OS, the versions of PHP, MySQL and all the other things that go along with a new Linux distribution. They sent me some emails last month, announcing this move and listing the changes that were going to happen. Because I didn't understand any of what they were talking about, I concluded I had nothing to worry about! Logic!

The first problem...

PHP is a great language for writing quick dynamic web pages. It's got a friendly a C-style syntax, with lax rules about declaring variables and nice built-in string handling. So, actually it's a lot like JavaScript. One nice feature is how it handles the input from web pages: it automatically creates variables for each of the querystring parameters and for each of the form inputs. If you have the querystring "http://www.mysite.com?foo=10&programID=42", it will create variables "$foo" and "$programID", give them the appropriate value, and you can just use them. Likewise, if you have a form with a text box called 'textBox', it will create a variable called $textBox and populate the value when the page is posted back. Magic.

Except...

There's a magic switch that can be set at the server level (so it affects every site on the server) called "register_globals". If you turn that off, PHP doesn't create those variables for you any more. And because you don't have to declare variables in PHP any script that uses those automatic querystring and form variables is going to start acting strange - all those variables are going to be empty when you access them. And, of course, when they upgraded PHP on that server, they flipped that switch and turned off the automatic variable creation. I guess it's considered safer to turn that off? But whatever the reason, all the scripts on our site stopped working, silently, last week. I didn't know about it until a frustrated user sent me an email complaining that he couldn't purchase one of our products. Things had been broken for a week, by then. Awesome!

The fix is to replace all the variables that come from the querystring with $_GET['variableName'] and all those that come from a form with $_POST['variableName'], and do some gymnastics in places where the script was grabbing the value from either place. It wasn't difficult to fix them all, but putting out fires is never fun.

Lesson: Don't use handy built-in features?

The second problem...

We have a program on the site to generate license files for users. It's a C++ program that we built ourselves using a laptop that we'd set up identically to the server that hosts our web site (so we were using the same kernel, the same version of gcc, the same libraries, etc.). The server upgrade changed all those things, so our program stopped working - instead of creating the license, it just complains about a missing version of the libstdc++ shared library. Again, awesome! So, we're going to have to find a copy of the new OS that the server uses, install that on the laptop, rebuild the EXE, etc.. Why not just link statically, and avoid the whole shared library conflict? Because that's nearly impossible with gcc, that's why! Why not rewrite the program in a scripting language (like PHP and its magic switches!) ? Because this is a fairly complex program, with many encryption pieces, lots of data structure fiddling, and it took a ton of work to get it right in a full-featured dev environment (Visual Studio). Rewriting it in something where debugging consists of printing text to the console sounds like a total fucking nightmare. Even a rewrite in .Net sounds like hell.

Lesson: move the whole site to a host who will let me build binaries directly on the server via telnet/ssh ?

5 thoughts on “...And Now It Doesn't Work!

  1. cleek

    mmm taxes.

    here’s what i know about taxes: it costs me somewhere around $1000/yr to pay someone to tell me where to sign the forms and who to make the checks out to.

Comments are closed.