We ran into a weird problem at work today.  We use CodeIgniter for our web site, and due to some configuration (which, frankly, astounded me when I heard about it), we generate 404s on pages if we get unknown query string parameters.  We're testing integration with other systems, and some of them automatically add additional query string parameters when returning to our pages.

A solution was mooted that involved using a standalone PHP file that used file_get_contents with an HTTP URL to strip out the query string parameters.  Which is not the solution we want when we're trying to make sure we don't have performance-restricting aspects to our service — it would double up HTTP requests.

Normally, mod_rewrite doesn't interact with query strings — it maps the incoming resource to another resource, and query string parameters aren't part of the resource. But hidden in the mod_rewrite documentation is this:

Modifying the Query String

By default, the query string is passed through unchanged. You can, however, create URLs in the substitution string containing a query string part. Simply use a question mark inside the substitution string to indicate that the following text should be re-injected into the query string. When you want to erase an existing query string, end the substitution string with just a question mark. To combine new and old query strings, use the [QSA] flag.

In our case, we just added a question mark to the right-hand-side of the rewrite rule, and we saved ourself an HTTP request.

Over the weekend, I did the first PHP programming I've done this year, on a whim project to write a Amazon S3 storage manager for KnowledgeTree.

In KnowledgeTree, a storage manager describes where to and how to store and otherwise manage the files attached to documents in KT.  S3 is a remote storage web service from Amazon, allowing reliable, scalable, and net-speed-quick storage for data.  Most of the code ended up being around configuration - particularly in terms of making it easy to check whether the S3 storage manager is properly configured.

This starts with a status dashlet (a dashboard "portlet" - a little bundle of information on the "front page"), which makes it hard to miss if you haven't configured things yet:

(It also tells you if you haven't told KnowledgeTree to use the S3 storage manager.)

The S3 Storage adds an administration page, allowing through-the-web configuration of the plugin.  One of the things I'm sorry I never got around to was getting configuration in KT pushed more into the database - the constant push for "cool" features meant the basics that affect actual users never got any time.  Before configuration, the page looks like this:

The "No" next to testing reminds administrators whether they've done a test of the settings they've entered.  The "Test now" makes it easy to see if the settings are correct without trying to add a document.

The Amazon Web Services settings are quite boring, since they can't be detected.  But, for the S3 configuration, we can query the available storage buckets and present the information to the user:

Once you've set it up, it's actually quite sad how it "just works".  There's no difference in terms of using KnowledgeTree to add, bulk add, or delete documents (except that it's a bit slower for those poor South Africans with not-so-wonderful connectivity).  Downloading is fast, since the files are cached locally.

The entire storage manager is only 250 lines of code, most of which is caused by the immaturity in the storage manager framework, because pretty much the only non-standard storage manager that we wrote was a in-database storage manager (which was quite slow, and thus was forgotten).  The admin page, status dashlet, and so forth come to 500 lines of code.  You can download the plugin in ZIP and tar.gz formats.

It seems KT's doing well - they were invited to attend the Olliance Group's Open Source Think Tank event later this year.  (Nice venue!  The Californian winelands have long been the #1 location I'd love to visit in the US, even before becoming even more enamoured after watching Sideways)

And (belatedly), they seem to be looking for developers again - if you can stand programming in PHP and want to be paid to work on an open source project in beautiful Cape Town, why not apply?

It's been three weeks since we release version 3.0.0, and things with KnowledgeTree have not been slow. On Monday, we released KnowledgeTree 3.0.1 and commercial support. On Monday too, we had our second most downloads on a single day (the most was on the 2nd when KT3.0.0 was released), and reached our highest monthly downloads (on the 20th of the month).

3.0...

What Brad said:

Beta 3 out

After way too many Windows-related nigglies, KnowledgeTree beta 3 is out. Grab a copy if you don't want my PHP and Windows sacrifices to be in vain. I'm increasingly wondering how people get some sorts of things done in PHP, especially when running with Windows. Python provides relatively seemless cross-platform support. PHP seems not to even let me run a program without invoking a shell (which requires an obscure permissions setting to work with services). And that command shell refuses to run escaped commands directly, forcing me to use Windows-specific hacks. Ug.
I'd intended to work on other bits of KnowledgeTree over the weekend, but I got a bit sidetracked on configuration for some reason. The thing about tangeants is usually that they're nowhere near as useful as the stuff they're leading you from, and I suspect that's the case here. But some aspects of using a PHP file for configuration have obviously taken root because I've now designed something ever so much more complex.
I'm in the second week of a contract Jam Warehouse has got to improve KnowledgeTree. The nice thing about it is that the items they want improved mapped very closely to what I thought needed improvement in KnowledgeTree. So, I had a head-start in thinking how to approach the improvements, and now I'm really looking forward to seeing things done right in KnowledgeTree soon. I'll chat a little bit about my progress as I go on. Not too much, I have set myself a tight schedule on this project - the final product is due on my birthday, September 27th.
One area in KnowledgeTree that gets a few problem reports is that of file uploads. Of course, being a document management system, it's rather important that KnowledgeTree handle this well.
I'm finally getting back into the swing of things with my project, the KnowledgeTree Document Management System. After umming and ahing a bit, it seems the work to get the basics working with PHP5 wasn't quite as hard as I thought it would be. The low-hanging bug fruit is hanging a bit higher now, but thankfully the community is providing more patches. Great things coming up with KnowledgeTree next month - Jam Warehouse has a contract for some major improvements, and we've got a surprise or two in store too.