Unable to disable error reporting in OpenCart (PHP)

I cannot disable error reporting in PHP. I tried everything, but the "Notifications" 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 really off and 0, and yet I still get a notification,

Note: Undefined variable: my_undefined_var in /my/site/path/index.php?blahblah ...

Please note that this is an OpenCart site (and my change is in the admin section). I tried to create a test php script in the same directory as index.php, and that is fine.

Is there anything else that could override error_reporting(0) ?

I did a grep of the whole site to find and turn off all references to reporting and display_errors errors, but to no avail.

+4
source share
5 answers

The OpenCart toolbar has a parameter that allows you to enable (or disable) error reporting and logging.

  • Log in to the control panel.
  • In the menu, go to "System" and select "Settings"
  • In the list of stores, click "Edit" for your store.
  • Go to the "Server" tab.
  • Scroll down and there are two settings:
    a. Log errors - fix this as soon as possible b. Display Errors - Set this parameter to None
+22
source

As @colmde already pointed out, OpenCart uses a custom error_handler.

You can turn off error display without any code changes (especially OpenCart kernel files) with:

Admin->System->Settings->[edit your configured store]->Server->Display Errors

[EDIT] You can do the same by running the following query in the OpenCart database:

 update setting set `value`= 1 where `key` = 'config_error_display' 
+11
source

OpenCart uses the set_error_handler() function, which forces it to override error_reporting(0) .

Removing this fixed issue.

+8
source

you can just use

 ini_set('display_errors', 0); 

in the system / startup.php

+3
source

The true path to OpenCart.

  $this->config->set('config_error_display', 0); $this->processAction(); // it throws ugly warning 

I tested in the controller of my module. Just to turn off error display in front of your code. This affects only the current session (possibly the current page). This does not affect the DB!

0
source

Source: https://habr.com/ru/post/1484592/


All Articles