Welcome Guest, Not a member yet? Register   Sign In
Un-suppress warnings?
#1

[eluser]darioism[/eluser]
I think that CodeIgniter is suppressing warnings that I'd like to see during the development process. I have my error reporting level set to "E_ALL & E_STRICT" in CodeIgniter's index.php file, and I purposefully put an undefined variable in one of my views as a test, but I don't get a displayed or logged notice/warning. PHP files outside of CodeIgniter but on the same website do log warnings properly, so I think CodeIgniter is changing something upon initialization. Thoughts? Thanks in advance.
#2

[eluser]Aken[/eluser]
Are you using CodeIgniter 2.0+? If so, the index file has a setting for development or production modes, which will set a new error_reporting level later on in the file. Make sure it isn't overwriting the error level you're setting.
#3

[eluser]darioism[/eluser]
Yes I am using 2.0.2, and I'm set to "development" mode, which I changed to E_ALL & E_STRICT.
#4

[eluser]Aken[/eluser]
Looking at the PHP manual, I don't know if that's the correct method of setting multiple error modes. Try this:
Code:
error_reporting(E_ALL | E_STRICT);
// OR
error_reporting(-1);
#5

[eluser]darioism[/eluser]
No dice there either... it just swims right past errors!
#6

[eluser]Aken[/eluser]
Can you show where you're trying to deliberately output an error in your view? Have you double checked your page's source code to see if it is hidden for whatever reason? Sometimes if errors are output in the middle of HTML tags or something, it won't get rendered the way you'd expect.

Do you have access to your php.ini file? If so, are either of the error settings there causing a conflict?

I just tested a fresh install of CI, tried to echo a non-existent variable in my view and received a notice error as expected. So it's either a setting or something else you're missing / forgetting. I'll help you find it, though.
#7

[eluser]darioism[/eluser]
Same as you, I simply echoed a non-existent variable in a view, and would expect to see a warning in my error log. Good thinking to check the source, but yeah I already looked. Just nothing there.

It can't be the php.ini settings. Another PHP file in the same website but outside of CodeIgniter does work as expected since I see the warning logged, so there must be something in CI itself which is suppressing the warning. Nothing out of the ordinary in the .htaccess file either. I'm lost!
#8

[eluser]Aken[/eluser]
Have you tried setting error_reporting() directly before you load the view? Give that a shot, see if it changes anything. If it does, you have an error_reporting() setting somewhere that is overwriting the setting in index.php. Focus on getting the error displayed in your browser, that's the more important thing.

Just so I'm clear, are you talking about PHP's error log file, or CodeIgniter's generated log files? I just checked my PHP error logs and it did NOT register the notice error, even though CodeIgniter displayed it properly. I then did the same in a non-CI file and it registered the error in my log.

I've gone through the source code some, and CodeIgniter is indeed using set_error_handler() to do it's own error handling (mainly for the purpose of logging PHP errors into CI's log files, in case the developer does not have access to them).

The problem with this is that doing so is that it overwrites PHP's built-in error handler, which is what sends data to the log files. If you overwrite it, you're supposed to use PHP's error_log() function to handle writing to log files. CodeIgniter does not currently do this.

I might put together a MY_Log file to extend this functionality for those who still want to log errors and such to their server files and not just CodeIgniters. I'll have to research best practices a bit more.
#9

[eluser]darioism[/eluser]
I think I'm narrowing down the issue, but not completely. Before loading CI, I load WordPress since the two have to be integrated for this project. Before including WordPress, the logging works as expected. However after WordPress is done loading, we set error_reporting() in CI itself. What else could WordPress be setting which turns off logging?
#10

[eluser]Aken[/eluser]
I don't know - WordPress is not a specialty of mine. It might come down to you needing to deliberately create errors in various places until they go away, and then trace it from there. Integrating two large-scale scripts like this can be a pain to see which is controlling what, especially if they're not separated into their own folders and such.

It's possible WordPress includes it's on set_error_handler() function as well.




Theme © iAndrew 2016 - Forum software by © MyBB