Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Bug in DB_driver.php method display_error() #1692
I noticed a bug in the method display_error() whilst looking for a way to generate neat error messages using the display_error() method.
I figured the best way to do this way to look how codeigniter handles errors itself.
I noticed that the backtrace is being evaluated to check which file and line-number is the culprit for the error, but I also noticed that database errors always show me the DB_driver.php class with line-number 330.
This shouldn't be the error found according to the condition:
isset($call['file']) && strpos($call['file'], BASEPATH.'database') === FALSE //line 1180
I found that the method strpos($call['file'], BASEPATH.'database') always returns false on the first call of the trace because $call['file'] and BASEPATH are formatted differently.
whilst print_r(BASEPATH) returns
This is a slashes vs backslashes issue...
replacing line 1180 by...
if (isset($call['file']) && strpos($call['file'], FCPATH.SYSDIR.''.'database') === FALSE)
seems to do the trick. It now shows the file causing the error...