With the addition of Josh M., he was now officially the 15th developer in the past 7 years to work on the small company’s HUGE PHP/MySQL web app.

The whole site seemed to be a WTF, and yet one part stuck out like a sore WTF-thumb. It was the 'static text' table.

It was clearly an attempt to put ALL of their HTML, multi-language labels, and any other bit of text into one convenient place, but any convenience was completely lost in the form of a maddeningly complex code base.

Every page started the same…

$sql_st="SELECT * FROM `static_text` ORDER BY `id_st` ASC;";
$result_st = @mysql_query( $sql_st , $connection ) or die( "Couldn't execute query: $sql_st;" . mysql_error() );

while($row_st = mysql_fetch_array($result_st))
{
    $st[] =stripslashes($row_st[st]);
}

… but the similarities between pages ended there.

Whenever a page needed to reference a specific bit of HTML, text, or whatever, the developer would pair up a variable with its associated array element.

<?php
$type_s="$st[24]"; 
$type_f="$st[25]";
$hover = "$st[124]";
$add_title = "$st[255]";
$first_line = "$st[106]<br/><br/>$st[244]";
$second_line = "";
$head_title="$st[18]";
$place ="$st[23]"; 
$trading="$st[28]";
$role="$st[27] $st[26]"; 
$add_title = "$st[389]";
$size = "links_car";
$comp_title ="$st[343]";
$role_title = "$st[344]";
$add_title1 = "$st[345]";
$add_title2 = "$st[346]";
$town_title = "$st[347]";
$county_title = "$st[348]";
$postcode_title = "$st[349]";
$country_title = "$st[350]";
$ref_fnm_title = "$st[269]";
$f_p_title = "$st[268]";
$ref_job_title_title = "$st[271]";
$ref_surnm_title = "$st[270]";
$work_num_title = "$st[273]";
$mob_title = "$st[274]";
$fax_title = "$st[275]";
$email_title = "$st[276]";
$trading_title = "$st[351]";
?>

<td width="133"><?php echo"$st[56] $st[38]"; ?> </td>

As evidenced by the longevity of the application, the logic does work. However, as Josh learned, that logic is shored up using some mighty weak stilts.

One day, a user had deleted several hundred rows with labels that had read “Obsolete - Do Not Use” from the static text table. Josh learned that in the previous 14 iterations of him, everybody had been diligent about saving application changes to the company's SVN, but nobody had thought about backing up the data. Oops.

After a day and a half of fiddling with the static table and adding rows that read “Obsolete - Do Not Use or DELETE”, Josh started thinking that a spot may be an opening for developer number 16 in the near future.