5

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.

Charles
  • 48,924
  • 13
  • 96
  • 136
colmde
  • 2,852
  • 1
  • 19
  • 42
  • What's the point in setting log_errors to 1? What do you want to log? – Your Common Sense Jun 05 '13 at 08:54
  • Besides that, the title makes me shiver naturally. – Your Common Sense Jun 05 '13 at 08:55
  • I don't really want to log anything... I was reading on another forum that to disable error displaying you may have to enable error logging - doesn't make sense to me but I am at the point where I'll try anything. But if I take it out it makes no difference – colmde Jun 05 '13 at 09:01
  • http://stackoverflow.com/questions/29986806/how-can-we-disable-error-log-in-opencart-error-store-on-databse/29986840#29986840 –  May 01 '15 at 12:55

6 Answers6

28

There is a setting within the OpenCart dashboard that allows you to turn on (or off) error reporting and logging.

  1. Log into your dashboard
  2. In the menu, go to "System" and select "Settings"
  3. In the list of stores, click "Edit" for your store
  4. Click the "Server" tab.
  5. Scroll down, and there's two settings:
    a. Log Errors - set this as desired
    b. Display Errors - set this to "No"
random_user_name
  • 23,924
  • 7
  • 69
  • 103
11

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'
zergussino
  • 811
  • 10
  • 14
  • 1
    For me worked: `UPDATE 'TABLENAME'.'oc_setting' SET 'value' = '0' WHERE 'oc_setting'.'setting_id'=1057;` – Harkály Gergő Apr 07 '16 at 13:21
  • Perfectly valid, and the reason is that you selected to use `oc_` prefix for OpenCart tables during setup, so `setting` turned into `oc_setting`. – zergussino Apr 07 '16 at 18:35
8

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

Removing this fixed my problem.

colmde
  • 2,852
  • 1
  • 19
  • 42
4

you can simply use

ini_set('display_errors', 0);

on system/startup.php

Abhinav bhardwaj
  • 2,205
  • 19
  • 21
  • I wanted to do the opposite: turn error reporting on (which turned out to be quite hard, but this works!) – Martijn Nov 11 '15 at 19:51
0

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!

0

for me helped: //error_reporting(E_ALL);

in file startup.php