logo
Header graphic 8 of 9

Categories

Archives

Other stuff

Other sites

I wish this site were powered by Django

July 28th, 2006

Typo3, PHP, MySQL connections and Unicode

Filed under: Attitude, Cutting the crap, PHP, Technology — jm @ 15:30

I have said it before and now I have to say it again.

Over the last three months I've spent a ridiculous amount of time on a Typo3 project for the Chair for Business Engineering at the University of Regensburg. We built a full-featured DMS based on Subversion, Typo3's DAM and WebSVN. We got hit by PHP's miserable Unicode support so hard, it isn't even funny anymore.

I always assumed that using Unicode strings with PHP can derail a project badly as soon as you run into one of the thousand's of possible problem scenarios, but now that it happened to me, I can prove it. What happened was that while Subversion, interestingly, fully supports UTF8-encoded log messages and URLs, it also gives an error and exits if it detects encoding errors. So on multiple occasions, when we built a log message in a PHP script by concatenating 2 Strings like $str = $strFromWebBrowser . $strFromPHP; we'd end up with an error message, because $strFromWebBrowser was UTF8-encoded by the browser, but $strFromPHP was not. We were able to fix this by enforcing internal UTF8 encoding using PHP's mbstring extension and limiting ourselves to the few string functions that mbstring does overload.

The second and really hard to debug problem that hit us was that Typo3 4.0 (Typo3's total crappiness is a topic for another post) still opens database connections using PHP's old mysql library. This means that if you want to work with MySQL 4.1 or better, you don't get support for all the fancy new binary protocol features, like the client character set support in the connection packet header. So now you have a database that's fully UTF8-encoded in MySQL 5.0, but every connection that Typo3 opens in its central database class class.t3lib_db.php has character_set_client set to "latin1". This means that if PHP sends UTF8 data across this database connection, the string is double-encoded. This also happens when Typo3's "force_utf8" option is set. It took a long night with hexdump and this ISO8859-1 to UTF8-table to figure this out and we fixed it literally in the last minute.

You might think that enforcing a client character set using MySQL's init-conn configuration option could solve the problem, but unfortunately MySQL seems to ignore this setting in the current release. So the only option was to patch Typo3's database code, inserting these two lines into the code:

@mysql_query('SET NAMES utf8',$this->link); @mysql_query('SET CHARACTER SET utf8',$this->link);

I still think that PHP's new mysqli library is crap, too, because the parameter binding is as bad as Java's (no named parameter support) and the resultset handling just sucks, but at least it fixes most SQL-injection attacks by supporting prepared statements. That Typo3 is still tied to MySQL as a database is just sad, but I can't decide what they should fix first, the ugly admin interface or their database code. I tend to the latter as you can't install Typo3's DAM extensions if you install their database abstraction layer (that nobody uses anyway), which is an undocumented dependancy, by the way, that hit us during the first few weeks of development.

So there you have it: please please please don't use PHP for a project if you have any other choice.

July 21st, 2006

Internet video from Lebanon

Filed under: General — jm @ 11:46

This doesn’t look like the “brink of war” anymore, does it: Back To Iraq - Video report. Christopher, if you ever come to Munich, Germany… I’m buying the drinks.

Israel is depopulating the southern part of Lebanon

Filed under: Deutschland, Politics — jm @ 00:25

The idea seems to be to create something along the lines of a DMZ. The people living there have been given 24 hours to leave. There’s currently no mention of this story on CNN, so consider it unconfirmed. My source: Eric Umansky.

There seem to be coordination problems within the EU on how to evacuate our citizens. Well, Berlin even sent a few busses to evacuate 3000 Germans from the region. In contrast, Great Britain and France sent their navies, with even the British aircraft carrier “HMS Illustrious” being on its way. Well, we Germans are not exactly known for our capacity to actually do something about anything :-/.

But whatever happens, especially the US american’ news services should finally recognize that the middle east is at war. As The Daily Show recently reported, according to CNN, 300 missiles hitting a city only brings a region “at the brink” of war… sigh.

July 20th, 2006

Finally

Filed under: Politics — jm @ 13:27

This is it! Steward Colbert ‘08

prototype.js Insertion.After bug in IE 6.0

Filed under: Technology, Web — jm @ 13:20

This bug bit me and fixing it was a pain. I finally found a fix in Andy’s comment at Rob Sanheim’s Panasonic Youth Weblog. The fix? Modify line 1032 in prototype-1.4.0.js to:

if (this.element.tagName.toLowerCase() == ‘tbody’ || this.element.tagName.toLowerCase() == ‘tr’) { this.insertContent(this.contentFromAnonymousTable()); }

Internet Explorer is a big piece of crap!

July 19th, 2006

more video stuff…

Filed under: Games, General — jm @ 23:03

Real-life space invaders great!

Game trailers

Filed under: Games — jm @ 21:55

Shiny new things:

Now.. if I only had more time :-)

July 13th, 2006

Entertainment CPU

Filed under: Games, Technology — jm @ 18:36

High-level overview of the Cell processor, the CPU(s) that powers Sony's Playstation 3. Nice!

July 10th, 2006

Sir Ken Robinson

Filed under: Education — jm @ 02:44

This is a great talk from this year’s TED conference. More after I’ve slept for a bit ;-)

July 08th, 2006

Antisocial Personality Disorder and the rape of young Iraqi women

Filed under: Cutting the crap, Politics, Psychology — jm @ 11:20

A great post on Respectful of Otters. The soldier being accused of raping a young iraqi woman has recieved a medical discharge from the army. However the diagnostic criteria don’t match the story a hundred percent.

To stay in the spirit of today’s posts, I’d love to know how many actual journalists looked up ASPD in the DSM IV

Next Page »