CodeIgniter’s log system issue

First of all I have to admit that I love this framework. I will write more about this fantastic framework later.

But one issue I faced this morning and I was pulling my hair was its logging system.

I was editing the module which has few Ajax calls, some part was not working properly and it was absolutely because of the SQL. We have the main SQL commands being outputed in the CI log system as well. So I SSHed to server and open the log file in vi , searched for the desired point and was trying to figure out what’s the SQL problem.

At this point I got a message from a colleague asking whether our server is down or what ?

That was so confusing, some parts of the application were working and some parts were not. All the sections which were working like a Swiss watch few seconds ago. So what was wrong!
As usual everything was working properly on localhost.
I didn’t even give it a small chance that having the log file open for reading [I’m stressing this out : JUST FOR READING] could be the problem. CI couldn’t proceed with logging in the sections where we had used it. I just quit the vi editor and Voila. Coming back to life.

This is not a proper approach for log system, if it can not write to the log file it shouldn’t prevent the whole system from working. Or may be it should ! Depends on how logging is important for your system.

CodeIgniter xss_clean semicolon addings

When you use that perfect xss_clean function from CodeIgniter’s library to make your content more robust, sometimes you may face a strange content being updated in DB having “;” after “&” or before “=” .

That “;” is added by xss_clean, to make the link more robust, but if in your case it will add some malfunctioning in your system you’d better use something else in your validations like “htmlentities” :

$rules['link']                =     "required|trim|htmlentities";

For more information regarding that you can refer to CI forums. [thread1] [thread2]