Previous Entry Share Next Entry
FUCK YOU CHRONOFORMS
verix wrote in fuckphp
So I'm trying to weasel my way into this company, right? They asked me to do some minor PHP work for them. I thought it would be a straight-forward task. You know, simple form modifcation here, e-mail setup there. I'd only have to worry about learning a little bit of Joomla! and apparently ChronoForms. Right? It should be that simple, right?

No, of course not, because it's a fucking CMS written in fucking PHP. Once again I am convinced that the use of the eval() function by a given program is directly correlated with its quality.

So here's what went down: this guy wanted me to display the address information of a user through Joomla! and ChronoForms. JUser does not contain this information-- so I had to pull it from the database, then proceed to display it. But each row follows a format-- so to save code, I do this:
$tableformat = "<tr><td align='right'><b>%s:</b></td><td>%s</td></tr>\n";

At this point I also find out that if I want to pass the information I pulled down when the form is submitted and the data e-mailed to the administrator of the site, I have to pass them as fucking hidden form variables. This is where things get interesting.
$hiddenformat = "<input type='hidden' name='%s' value=\"%s\">\n";

So I'm feeling pretty good because I saved a ton of code space. A few executions of sprintf() later with the formats as the printing arguments, the code is properly formatted and I'm happy about things.

I try to set up the thing to e-mail clients but apparently can't seem to do that from my jurisdiction on the Joomla! control panel. So I talk to the guy who sets some stuff up. But out of fucking nowhere, a bug appears. It's a crippling syntax error.

I try changing the "form code" crap on the site to see if that isolates the error-- nope, it doesn't. I go to the "generated code" section to tweak some stuff there to no avail because you can't actually do that whatsoever. I try looking at every single possible thing from my jurisdiction until finally I ask the guy if I can get access to the Joomla! code, because there was no other way I was going to debug this.

While most people would blame the programmer in this situation, I don't. I don't blame the programmer at all-- I blame this fucking language. I blame this fucking language because it encourages you to throw shit at the wall to make it work. I blame this fucking language because it encourages bad coding habits and all sorts of nasty bullshit.

In order to run your form code with embedded PHP, it uses eval(). Which is fine I guess, but annoying. But after looking through the eval() code, it also looks for <input> tags. SO HEY. GUESS WHAT IT FUCKING PICKED UP ON AS AN INPUT VARIABLE?! THAT'S RIGHT:
$hiddenformat = "<input type='hidden' name='%s' value=\"%s\">\n";

So when I asked the guy to set up e-mail, he had to make a new table to associate with the form. When he did that, one of the columns was named %s. THE PROGRAM NAMED THE FUCKING COLUMN %s. This wouldn't be so big of a problem, really, if ChronoForms wasn't such a third-rate piece of shit Joomla! component.

Say you have a table that has the columns "foo", "bar" and "baz." When you associate this table with a form in ChronoForms, ChronoForms makes things """EASIER""" for you by adding procedurally generated code somewhere in the database that looks similar to this garbage:
if (!classexists("jos_chronoforms_MyBigFatGreekTable") {
class jos_chronoforms_MyBigFatGreekTable {
var $foo = null;
var $bar = null;
var $baz = null;
}
}

It then proceeds to later on eval() this fucking code. So when it generates the table, it basically makes a bunch of variable names in a class based on the column name. AND GUESS WHAT?? SOME CHARACTERS YOU JUST CAN'T HAVE IN A VARIABLE NAME, FOR EXAMPLE, %!! WOW SO GUESS WHAT HAPPENS WHEN YOU HAVE A VARIABLE NAMED $%s?!

THAT'S RIGHT

EVERYTHING FUCKING BREAKS.

So after manually dropping the fucking column and manually fixing the entry in the database that has that stupid fucking classexists function up there (THERE WAS PHP CODE STORED IN THE FUCKING DATABASE AUGH) the bug disappears. My form code then looks ugly as shit and is horribly inflexible because apparently being clever completely fucking breaks ChronoForms.

Thanks ChronoForms you did an amazing job at making things totally easier for me. You are a wonderful, brightly shining star in the world of PHP. Fuck you.

?

Log in