The Dev Pages

A knowledge base for simple (and beyond) web applications development

Archive for May, 2010




In what was one of the worst bugs I have come across in a while, mainly my fault, I learned the hard way that using the name ‘length’ for an object attribute may be a bad idea. Along the same lines as using ‘window’ as an attribute name. These things tend to cause clashes in framework and javascript libraries.

So more specifically with the yii framework, which uses jQuery to handle gridview filtering, I debugged the hell out of other people’s JavaScript code until I learned from line 59 on the jQuery core library that the each method on a jQuery object uses the length property of a jQuery and javascript object to iterate over its properties.

It goes as follows. Say I have a ‘windowdrape’ table and object. This has a length and width, in inches, of how big the drape is. So I make a ‘length’ column. The yii framework hands my model object off to javascript. So now in javascript I have a windowdrape object. So WindowDrape.length to jQuery is how many attributes the WindowDrape has. I expect it to be how long the window is in inches. So I set it to 98, and now all of a sudden jQuery will iterate the thing 98 times, and the attributes on WindowDrape are all messed up because of the bogus length attribute.

The lesson here, especially if you use the yii framework is Don’t name a column or model object attribute ‘length’. These things are also why I avoid using ‘name’ or ‘window’ etc. for attribute names.




So if you need to explicitly set the upload-pack path on a git command using the msysgit shell, you’ll get a weird error. Apparently msys mucks up (in a lot of cases this is actually the desired behavior) paths. MSys alters the unix style path you entered to be windows style and prepends it with C:\PATHTOYOURGIT. This obviously confuses the server and causes a msysgit error on upload pack.

bash: C:/Git/PATHTOYOURUPLOADPACK/git-upload-pack: No such file or directory
fatal: The remote end hung up unexpectedly

So to fix this (which was a pain in the ass to find!) you simply begin path arguments with an extra slash.

git clone –upload-pack /home/myuser/bin/git-upload-pack myuser@mydomain.com:/home/myuser/gitprojects/agitproject.git

becomes

git clone –upload-pack //home/myuser/bin/git-upload-pack myuser@mydomain.com:/home/myuser/gitprojects/agitproject.git

http://osdir.com/ml/msysgit/2010-03/msg00139.html

- If you want to specify a different location for –upload-pack, you have
to start the absolute path with two slashes. Otherwise MSys will mangle
the path. git and bash have serious problems with non-ASCII file names
(Issue 80, 159).