11

I am running an application which is riddled with error_reporting calls, but I'm running PHP 5.5 which has a lot of depreciated warnings. I have configured my php.ini file correctly like this.

error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT

But all of the error_reporting() calls override it. Is there any way I configire to ignore runtime calls to error_reporting()?

Changing all the error_reporting() calls is a real hassle, especially as the application will need to be regularly updated and I want to avoid running a post install hack script.

I don't want to mention the name of the app, it's VBulletin 5.

4
  • "I don't want to mention the name of the app, it's VBulletin 5." Yep. If there is an error_reporting() call in an application, this is a hint for bad PHP developers. error_reporting should ony be set via the server configuration (i.e. php.ini). Commented Oct 25, 2013 at 12:42
  • str_replace('error_reporting', '', $code); ;-) Commented Oct 25, 2013 at 12:44
  • It would be nice if you could "force" redefine a function. like you can do in JavaScript. Oh well. Commented Oct 25, 2013 at 12:50
  • In VBullentin there are a lot of calls to chanage to error reporting. And I meant A LOT. On one of my dev machines I'm running a higher version of PHP than is supported. VBullentin is proprietary code so helping to improve the code is not an option especially when we will be rolling out updates as they are released. If you read the original post, I think I make myself quite clear. Commented Nov 7, 2013 at 15:53

2 Answers 2

10

There is an ini-setting disable_functions, which you could use to disable the error_reporting() function. That way the application can not set the error reporting level via this function.

disable_functions = error_reporting

Only internal functions can be disabled using this directive. User-defined functions are unaffected. This directive must be set in php.ini For example, you cannot set this in httpd.conf.

See: http://www.php.net/manual/en/ini.core.php#ini.disable-functions

Sign up to request clarification or add additional context in comments.

1 Comment

Combating evil with extreme evil. I like it! +1 :)
5

If you have control over the webserver configuration you can use php_admin_value to set error_reporting to a value that cannot be overriden.

According to the documentation this cannot be used in a .htaccess file, so you will have to use it on the whole server ... maybe a little too much.

Another possibility would be to use disable_functions to disable error_reporting. Downside would be that you will get a warning every time it is used, but you can get around that:

You can add a section to your php.ini that only affects the specified script:

[PATH=<path>]
error_reporting = 0
disable_functions = "error_reporting"

1 Comment

Hahah. Yeah warnings, but this is the sort of thing I was thinking of. Ta

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.