Thoughts filed in: Words of wisdom

Prev 1 2
28
May

Installing the uploadprogress PECL extension on Leopard

The uploadprogress PECL extension is a PHP add-on that allows cool AJAX uploading like never before. Version 3 of Drupal's FileField module is designed to work best with uploadprogress enabled. As such, I found myself installing a PECL extension for the first time. No doubt, many other Drupal developers will soon be finding themselves in the same boat.

Unfortunately, for those of us on Mac OS X 10.5 (Leopard), installing uploadprogress ain't all smooth sailing. The problem is that the extension must be compiled from source in order to be installed; and on Leopard machines, which all run on a 64-bit processor, it must be compiled as a 64-bit binary. However, the gods of Mac (in their infinite wisdom) decided to include with Leopard (after Xcode is installed) a C compiler that still behaves in the old-school way, and that by default does its compilation in 32-bit mode. This is a right pain in the a$$, and if you're unfamiliar with the consequences of it, you'll likely see a message like this coming up in your Apache error log when you try to install uploadprogress and restart your server:

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/php5/lib/php/extensions/no-debug-non-zts-20060613/uploadprogress.so' - (null) in Unknown on line 0

Hmmm… (null) in Unknown on line 0. WTF is that supposed to mean? (You ask). Well, it means that the extension was compiled for the wrong environment; and when Leopard tries to execute it, a low-level error called a segmentation fault occurs. In short, it means that your binary is $#%&ed.

But fear not, Leopard PHP developers! Read on for some instructions for how to install uploadprogress by compiling it as a 64-bit binary.

15
Apr

Self-referencing symlinks can hang your IDE

One of my current Drupal projects has been giving me a headache lately, due to a small but very annoying problem. My PHP development tools of choice, at the moment, are Eclipse PDT and TextMate. Both of these generally work great for me. I prefer TextMate if I have the choice (better config options + much more usable), but I switch to Eclipse whenever I need a good debugger (or a bit of contextual help / autocomplete). However, they haven't been working well for me in this case. Every time I try to load in the source code for this one particular project, the IDE either hangs indefinitely (in Eclipse), or it slows down to a crawl (in TextMate). I've been tearing my hair out, trying to work out the cause of this problem, which has forced me to edit individual files for several weeks, and which has meant that I can't have a debugger or an IDE workspace for this project. Finally, I've nailed it: self-referencing symlinks are the culprit.

The project is a Drupal multisite setup, and like most multisite setups, it uses a bunch of symlinks in order for multiple subdomains to share a single codebase. For each subdomain, I create a symlink that points to the directory in which it resides; in effect, each symlink points to itself. When Apache comes along, it treats a symlink as the "directory" for a subdomain, and it follows it. By the time Drupal is invoked, we're in the root of the Drupal codebase shared by all the subdomains. Everything works great. All our favourite friends throw a party. Champagne bottles pop.

The bash command to create the symlinks is pretty simple — for each symlink, it looks something like this:

ln -s . subdomain

Unfortunately, a symlink like this does not play well with certain IDEs that try to walk your filesystem. When they hit such a symlink, they get stuck infinitely recursing (or at least, they keep recursing for a long time before they give up). The solution? Simple: delete such symlinks from your development environment. If this is what's been dragging your system down, then removing them will instantly cure all your woes. For each symlink, deleting it is as simple as:

rm subdomain

(Don't worry, deleting a symlink doesn't also delete the thing that it's pointing at).

25
Feb

Step one: consume less

Consume less, and all else will follow. It's as simple as that. The citizens of the modern developed world are consuming far above their needs. The planet's resources are being gnawed away, and are diminishing at an alarming rate. The environmental side-effects are catastrophic. And the relentless organism that is our global 21st-century economy rolls ever on, growing fatter every year, leaving ever less pockets of the Earth unscathed, and seemingly unstoppable. But despite the apparent doom and gloom, the solution is ridiculously simple. It all begins with us. Or perhaps I have it all wrong: perhaps that's precisely why it's so complicated.

09
Feb

You're part of this world... aren't you?

For the past century, humanity has fallen into the habit of wreaking ever-more serious havoc upon the natural environment, and of conveniently choosing to ignore any and all side-effects that this behaviour may entail. Our daily lives are a crazy black comedy of blindness: each of us is like a blind butcher who carves up his customers, thinking that they're his animal meats; or like a blind man in his house, who thinks he's outside enjoying a breeze, when he's actually feeling the blizzard blowing in through his bedroom window. Finally, however, more and more people are taking off the blindfold, and realising that they do actually exist in this world, and that closing the window isn't the answer to stopping that breeze from getting warmer.

15
Nov

Pleasure vs pro

It's become popular in recent times for people to quit their boring day jobs, and instead to work full-time on something that they really love doing. We've all heard people say: now I'm spending every day doing what I enjoy most, and I couldn't be happier. Call me a cynic, but I am very dubious of the truth of this approach. In my experience, as soon as you turn a pleasurable pastime into a profession, you've suddenly added a whole new bucket of not-so-enjoyable tasks and responsibilities into the mix; and in the process, you've sacrificed at least some of the pleasure.

19
Aug

Stop shining that light in my face

Evangelism. For centuries, many of the world's largest and most influential religions have practiced it. The idea behind evangelism is that one particular religion is the one true way to find G-d and to live a good life. It is therefore a duty, and an act of kindness, for the followers of that religion to "spread the word", and to help all of humanity to "see the light". I say to all evangelists: stop shining that accursed light in my face!

16
Jan

Always read the book first

After a recent experience where watching the movie ruined my subsequent reading of the book, I've decided to be firmer than ever in my opinion that reading the book first is always a good idea.

Prev 1 2