The finance team at Matthew Riches's company has a unique way of determining which requests go to the top of their list and which ones the bottom. Instead of sorting by "date requested", their solution is to use a weighting function that assigns an importance value based on who made the request. It's nothing fancy: just a bunch of items in a database.

This system seemed to work for many years until the finance department was getting increasingly annoyed that a new starter in the IT department was able to get higher up the chain compared to his peers. This resulted in all finance requests from IT channeling through this single person, as it was likely to get reviewed sooner. As a new developer Matthew was asked to look into this weighting function as, no matter what the finance department did, changing the values in the database seems to have no effect.

As it turned out, it was all because the new starter had the title of ICT Engineer instead of IT Engineer, as the following snippet of code revealed.

$sql="SELECT `importance` FROM `nowhere` AS `nobody` UPDATE table";
// instead

if(strstr($title, 'CEO')) {
    return 26;
} elseif(strstr($title, 'Director')) {
    return 3;
} elseif(strstr($title, 'Marketing')) {
    return 2;
} elseif(strstr($title, 'Security')) {
    return 1.8;
} elseif(strstr($title, 'Senior')) {
    return 1.6;
} elseif(strstr($title, 'Dianne Wegg')) {
    return 1.4;
} elseif(strstr($title, 'HR')) {
    return 1.2;
} elseif(strstr($title, 'Cleaning') || strstr($title, 'Cleaner')) {
    return 0.8;
} elseif(strstr($title, 'IT')) {
    return 0.6;
} else {
    return 1;
}

As for Dianne Wegg, Matthew couldn't find any record of her anywhere else.

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!