WTF

UPS sends a package that had already made it to Rockhill, SC back to Columbia, SC so it can go back up to Charlotte, NC. What is going on?

How to operate Symfony in a virtual folder

Problem:

I needed to run symfony in a virtual subfolder under an existing site, so that the asset URLs generate by helpers still originate from the root folder while URLs generated from routes contain the virtual subfolder. For example:

I have a site xyz.com that is run on some legacy platform that uses the same sort of layout for assets as symfony (stylesheets in /css, etc.). All the traffic for xyz.com goes through a load-balancer that splits off requests which URL starts with the prefix /symfonyApp and sends them to the server(s) running the symfony app. Symfony needs to generate asset URLs that look like /images/logo.gif while generating action URLs looking like /symfonyApp/signup/index.

Analysis:

The reason I was able to make this work at all is that the helper functions and the routing classes use different ways to insert the prefix folder name. Helpers get something called “RelativeUrlRoot” from the request object. This value can be set in factories.yml. Otherwise, it’s calculated on demand by taking whatever is in front of the script file name in the SCRIPT_NAME environment variable.

Routes, on the other hand, store the prefix internally, though it’s initialized to “RelativeUrlRoot + ScriptName”, unless you override it in factories.yml.

Solution:

One solution would be to set the desired prefix values in factories.yml. But that requires duplicating the desired environment, which would be a pain to replicate. Instead, I opted to modify the values in the script file prior to dispatching the request. This way seems to work smoothly.

<?php

$tmp = dirname(__FILE__);
ini_set(‘error_log’, $tmp . ‘/../../log/frontend_virtual_prod-error.log’);

require_once($tmp.’/../../config/ProjectConfiguration.class.php’);

$configuration = ProjectConfiguration::getApplicationConfiguration(‘frontend’, ‘prod’, false);
$context = sfContext::createInstance($configuration);

// set separate prefixes for assets and links
$context->getRequest()->setRelativeUrlRoot(”);
$routing = $context->getRouting();
$routingOptions = $routing->getOptions();
$routingOptions['context']['prefix'] = ‘/symfonyApp’;
$routing->initialize($context->getEventDispatcher(), $routing->getCache(), $routingOptions);

$context->dispatch();

Vonage

I’ve recently switched home phone service to Vonage, away from my local cable provider which was providing basically the same service (VOIP) with less features for more money. A service I hardly used anyways. The most egregious bug/feature with the old company was that I HAD to dial “1″ in front of every number with a different area code, while for numbers within my area code, I HAD to leave out the area code. Pair this with the fact that the caller ID service they provided didn’t normalize numbers to account for their idiosyncratic and completely retarded system, and you have a major stroke-inducing situation at your hands.

Anyways, I made the switch and I couldn’t be happier to have access to modern age phone service. I can manage my voice mail box from my browser and voice mails are emailed to me as a .wav attachment. I don’t like voice mail in the first place so that makes it much more pleaseant to use this necessary evil. I am always delighted when competion and innovation create a benefit I actually care about.

New memcache client / updated old memcache client

It’s a sad truth that many good and relatively popular open source projects die a slow death because they lose there maintainers and nobody steps up to replace them. One example would be PHPEclipse, a remarkebly stable and feature rich PHP plugin for Eclipse. For the longest time, it was leaps and bounds above PDT, the “official” PHP plugin. (PHPEclipse has recently been revived) The issue is only exacerbated if language the project is written in is unfamiliar to its user base. Eclipse plugin development (Java) is a huge leap even for a professional PHP developer.

This sort of problem strikes far less often when the project in question plays an important part in a successful company, since they have the resources to pay someone to contribute/maintain. It’s not a guarantee though. Memcache is an excellent example. It was developed by Danga for internal use in Livejournal. It was later made public and quickly became intensely popular. The server part is in pretty good shape, although there are only about 2 releases a year. Facebook is contributing heavily now, though. Hopefully, we will see the benefits of those contributions soon.

The client library is another matter. Development there has been pretty anemic, probably coinciding with Dango’s aquisition by six apart (just a guess). The C library libmemcache which serves as the underlying implementation for the higher-level language specific libraries is not being maintained anymore. The perl library has seen no update in almost 2 years. The other script languages seem to be doing better. Even PHP, which PEAR/PECL projects often suffer from abandonment issues, has been steadily maintaining their client library and even has a new major release in beta right now.

Even so, the underlying problem remains that libmemcache is dead. From digg’s technology blog I now hear that not only is there a new C client library under heavy development (libmemcached), but they also hired a PHP developer to work on a new PECL extension that utilizes the new library. This is excellent news and should give memcache’s client side a much needed boost to go along with the upcoming server side improvements.

Quick thought

For some reason the comment spam bots love my “Learning Erlang” post.

New AWS Cloudfront pricing

First Petabyte is $78,000, every subsequest Petabyte is $50,000 (that’s just for the traffic). I’m sure everyone appreciates the lower prices. I know I do.

What’s going on at Microsoft? The usual…

The problem with a company the size of Microsoft is that you can’t reliably gauge how well it is doing why looking at any one part of it. The operating system division seems at least somewhat committed to return to sanity. Search is busy not gaining any market share. Hotmail is still useless. Enterprise software is finding new ways to package old software, same as ever was. And gaming is actually doing pretty well.

Console gaming anyways. Microsoft took it among themselves to, what I can only very generously describe as, try and unify gaming-related services through a Xbox Live related abomination called Games for Windows Live. They started this out by shoving their “solution” down the throat of every developer who wanted to publish an Xbox 360 game for the PC.

Now, the idea makes sense. Having one account for both Xbox and PC gaming. The implmentation is where it starts hurting.

Tycho over at Penny-Arcade noticed that when logging into Games for Windows Live, the same account on Xbox Live would get knocked offline. He then taled about this issue to a Microsoft person:

I spoke to someone from Microsoft about this very thing, and they said it was interesting, but asked how it would work mechanically. Where would messages be sent? Would one take precedent over the other?

If this is the kind of issue that causes them problems then their problems are, quite frankly, richly deserved. Just have one central place where messages go and other customized views for different access points. It’s not a hard thing to do, we’ve been using that approach for email for 25 years.

Compounding the problem is that instead of working to solve it before rolling out GfWL, they just made it impossible to log in outside of a game. Supposedly, they thought you might not notice getting kicked off Xbox Live if you start a game on your computer or laptop. Considering that they are marketing both platforms as things that go far beyond gaming, this is just cringe-inducingly stupid.

Update: This is relevant.

Home-made range voting applet

Last week, I decided to start on a project that I’ve been thinking about ever since I read this book review sometime during the early part of presidential campaign. It talked about how we could improve the elections by replacing the simplistic majority vote system with range voting. What it comes down to is that instead of picking 1 item out of a range of options, just to grade every option by itself.

It stuck with me that not even the most technology savvy political blogs and website out there used range voting for their polls. I don’t know why I didn’t just do it when I had the idea but I did it now, and I managed to whip up a javascript based widget that works across domains and can be placed on any website by including 1 or 2 lines of script.

I included one poll below and I hope it works across most browsers. It’s just a couple of hours coding so it’s hardly done and I did no cross browser testing.

Weird symfony error

This error popped up today just when I wanted to go home, and I really didn’t know what to do at first.

Warning: session_start() [function.session-start]: Function spl_autoload_call() hasn’t defined the class it was called for in…

I just googled it and thankfully someone else had encountered the same issue. Had I thought about it for a minute, it probably would come to me because it’s entirely logical. “spl_autoload_call()” is the function symfony defines to load classes on demand. The error message indicates that the function returned without defining (via include) the class it was called to define, and that this happen during session_start, i.e. when the session data is being deserialized. Symfony creates and caches an assosiative array of all class files that apply to a given application context, instead of trying to find classes on the fly or guess their location. What happened in my case was that I hadn’t defined the different session cookie names for two different applications correctly. In one application I had an object in the session which class was specific to that application. Then I switched to the other application, it tried to deserialize the same session instead of creating a new one and was unable to find the class of that object. Hence the error message.

new Symfony 1.2.2 breaks sfDoctrinePager

Symfony 1.2.2 is, ironically, a bugfix release. It happens to break sfDoctrinePager. This probably slipped past because it was broken by a commit intended to fix some problem with generated code. There’s tests covering that but no test for normal usage of the pager.

I filed a ticket here.

Update: Bug has been fixed for the next version.