Bug in DB_driver.php method display_error() #1692

Closed
bolemeus opened this Issue Aug 8, 2012 · 4 comments

Comments

Projects
None yet
3 participants
@bolemeus

bolemeus commented Aug 8, 2012

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.

print_r($call['file']) returns:
C:\www\test\frontend\system\database\DB_driver.php

whilst print_r(BASEPATH) returns
C:/www/test/frontend/system/

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...

@timw4mail

This comment has been minimized.

Show comment Hide comment
@timw4mail

timw4mail Aug 8, 2012

Contributor

Could you send a pull request?

Contributor

timw4mail commented Aug 8, 2012

Could you send a pull request?

@bolemeus

This comment has been minimized.

Show comment Hide comment
@bolemeus

bolemeus Aug 8, 2012

I'm quite new to git, but I'll try. ;)

bolemeus commented Aug 8, 2012

I'm quite new to git, but I'll try. ;)

@bolemeus

This comment has been minimized.

Show comment Hide comment
@bolemeus

bolemeus Aug 8, 2012

I've made a pull request according to a github guide, but I accidentally duplicated the issue...
The other issue is issue #1693

bolemeus commented Aug 8, 2012

I've made a pull request according to a github guide, but I accidentally duplicated the issue...
The other issue is issue #1693

@timw4mail

This comment has been minimized.

Show comment Hide comment
@timw4mail

timw4mail Aug 8, 2012

Contributor

Pull requests automatically create issues.

Contributor

timw4mail commented Aug 8, 2012

Pull requests automatically create issues.

narfbg added a commit that referenced this issue Oct 5, 2012

@narfbg narfbg closed this Oct 5, 2012

nonchip pushed a commit to nonchip/CodeIgniter that referenced this issue Jun 29, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment