Can't disable error reporting in OpenCart (PHP) - php

I can't seem to disable error reporting in PHP - I have tried everything but "Notice" errors are still displayed.
My php.ini has
display_errors = Off;
error_reporting = 0;
My .htaccess has
php_value error_reporting 0
And my script has
ini_set('display_errors', 'Off');
ini_set('log_errors', 1);
ini_set('error_reporting', 0);
ini_set('display_startup_errors', 'Off');
php_info();
echo $my_undefined_var;
The php_info() output confirms that display_errors and error_reporting are indeed off and 0, and yet I still get a notice,
Notice: Undefined variable: my_undefined_var in /my/site/path/index.php?blahblah...
Note this is an OpenCart website (and my change is in the Admin section). I have tried creating a test php script in the same directory as index.php and it's fine.
Is there anything else that could be overriding the error_reporting(0) ?
I've done a grep of the entire site to find and disable all mentions of the error_reporting and display_errors but to no avail.

There is a setting within the OpenCart dashboard that allows you to turn on (or off) error reporting and logging.
Log into your dashboard
In the menu, go to "System" and select "Settings"
In the list of stores, click "Edit" for your store
Click the "Server" tab.
Scroll down, and there's two settings:
a. Log Errors - set this as desired
b. Display Errors - set this to "No"

As #colmde already pointed OpenCart uses custom error_handler.
You can turn error displaying off without any code edits (especially OpenCart core files) via:
Admin->System->Settings->[edit your configured store]->Server->Display Errors
[EDIT]
You can do the same by running following query against OpenCart database:
update setting set `value`= 1 where `key` = 'config_error_display'

OpenCart uses the set_error_handler() function which causes it to override the error_reporting(0).
Removing this fixed my problem.

you can simply use
ini_set('display_errors', 0);
on system/startup.php

True way in OpenCart.
$this->config->set('config_error_display', 0);
$this->processAction(); // it throws ugly warning
I've tested in the controller of my module.
Just to turn off showing errors before your code.
It affects only current session (perhaps even current page).
It doesn't affect the DB!

for me helped:
//error_reporting(E_ALL);
in file startup.php

Related

Why is the wordpress fatal error not being displayed?

Our site was migrated due to issues on our server providers end. It caused many errors and I fixed most of them. Now, for some pages, it just says there is an error. It display notices and a depreciated warning but I know this will not cause the entire page to stop working. Why is the fatal error not being displayed?
This is what I have tried.
define( 'WP_DEBUG_LOG', 'error.log' );
ini_set('display_errors','on');
ini_set('error_reporting', E_ALL );
define('WP_DEBUG', true);
define('WP_DEBUG_DISPLAY', true);
error_reporting(E_ALL);
Normally it would show a fatal error. I don't know why it isn't showing me the important error.
Please help!
First ensure that there is no place in your code where you set error_reporting to 0
e.g.
error_reporting(0);
as this will totally hide all error warnings and notices.
In php script, this three line of code will just turn it on
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
You should see the same messages in the PHP error log.
Other things that you will need to check
1.) PHP.INI Files or your Apache configurations
You can move to your php.ini files and ensure that the following parameters below are commented out and set on.
By commented out, I mean removing a semicolon**(;)** at back of it
Eg.
uncomented = ;display_errors=On
commented = display_errors=On // semicolon removed
display_errors=On
display_startup_errors=On
track_errors = On
html_errors=On
shutdown and restart apache for it to take effect.
2.) .HTACCESS Files
You can also check .htaccess files to see if any of these warning parameter flags are set to 0 which means off and set them to 1 which means On.
Remember to turn off all these error warnings in production.

No detailed error messages

I am getting internal server error when calling php script via ajax. I set ini_set("display_errors", 1); error_reporting(E_ALL); but still no details .. what else should I do
inside your php.ini the
display_errors = On
The php.ini file is where base settings for all php on your server, however these can easilybe overridden and alterd any place in the PHP code and affect everything following that change. This happens a in frameworks. A good check is to add the display_errors to you php.ini. If you don't see an error, but one is being logged, insert this at the top of the file causing the error:
ini_set('display_errors', 1);
error_reporting(E_ALL);
If this works then something earlier in your code is disabling error display.

Display Errors only when I specify error_reporting Level

I've re-configured my Apache and now I want it to run in a better way.
To be more precise, I want to configure php.ini in such a manner that errors will only be displayed when I specify error_reporting so by default they wouldn't be displayed. This is because I'm developing a platform and I want to see errors as I go, then stop them for showing without having to go through the php.ini hassle.
I tried display_errors = Off but that wouldn't display errors even after I specify error_reporting level.
Ideas ?
First of all you should learn more about how you have to configurate your php.ini and know which command do what.
If you deactivate to display the errors there will be no errors displayed even if you set an error level.
But here is your answere: php.net
<?php
if (!ini_get('display_errors')) {
ini_set('display_errors', '1');
}
?>
with ini_set() during the execution of the script your options take action, after execution it is back to default.

Errors not displaying in PHP 5.3

I recently upgraded to PHP 5.3.22 and now I'm getting WSODs whenever there are errors in my php code. I know I have display_errors disabled in php.ini, so I tried adding the following code to the top of my scripts to temporarily enable displaying errors on the screen for debugging.
error_reporting(E_ALL);
ini_set('display_errors', '1');
The above works if I have an undefined function but if I miss a semi-colon at the end of a line, it still displays a WSOD.
How can I get all errors to display on screen when I'm developing the scripts?
Enabling error reporting at run time like that fails to show fatals. You can enable it in your php.ini or add this to your htaccess to override it:
php_value display_errors 1
As the file cannot be parsed, setting the error level and display_errors inside the file is having no effect.
Set it in your php.ini

PHP on OpenShift: How to enable errors and warnings?

I have moved my app to OpenShift and now, for convenience of getting it actually work, I'd like to enable in-page errors and warnings. Currently, I see a blank page.
How can I enable errors?
In PHP, it's in php.ini
error_reporting = E_ALL
display_errors = 1
On the IRC channel #openshift, I was told that this is not currently not configurable
(05:06:58 PM) pmorie: ozizka-ntb: it looks like it's provided by the cart - i don't believe you can substitute your own
and I need to use both
error_reporting(E_ALL);
ini_set('display_errors', 1);
You might want to set APPLICATION_ENV to development.
$ rhc env set APPLICATION_ENV=development
According to https://developers.openshift.com/en/php-getting-started.html,
In development mode, your application will:
Show more detailed errors in browser
Display startup errors
Enable the Xdebug PECL extension
Enable APC stat check
Ignore your composer.lock file (if applicable)
If you can't access php.ini then write this on top of your php page:
<?php
error_reporting(22527);
?>
This displays all errors and warnings in the page.

Categories