Jun
09
2015
PHP rants

-or how i spent a morning fixing something that didnt need fixing !!!

 

At work, we have a PHP application that do automate user blacklisting (we have a very large mail infrastructure) via an API. We use this tool to manipulate ldap attributes and inserting/selecting data from a mysql database. Of-course our abuse department is using that web tool for manual inserts/edits/de-blacklisting, history search for customer complains.

 

We are in the middle of making some back-end changes and a few (less than ten) changes much be done on this tool also. Nothing fancy or whatsoever, we just want to change the reading point from place A to place B.

 

Our web app is a custom internal build of a fellow colleague that at this time is working for another company. So I take charge to this easy and simple task.

 

Five minutes later and all the changes were made. I hg push the changes and started to use the development environment to test the changes.

And boom.jpg nothing is working !!!!

What-the-feck ?

Did a hg diff and see the SEVEN (7) tiny changes on the code.

To clear some things up, the changes was in the below form:


// read from ldap the attribute Profile
$attr_old = array ("Profile" );

// write to mysql the value of Profile
$old_profile = $entries [$i] ["Profile"] [0];

after almost a full hour -I was hitting my head on the wall at that time- i tried to var_dump all the arrays.

And WHAT I see, was unreal !!!

The code is reading the ldap attribute: Profile from the ldap as Profile.

BUT

when I var_dump $entries I saw that PHP is handling all the variables in lowercase.


so Profile is becoming profile

I still dont know/understand whys is this happening!
I just did two more tiny changes, so that mysql is now inserting


$entries [$i] ["profile"] [0];

and not the wrong one:


$entries [$i] ["Profile"] [0];

and everything is OK now.

Tag(s): php

Add comment

Fill out the form below to add your own comments