3
votes

I just started getting some warnings both on the front and back end (using Wordpress) of a site I'm working on. Error reporting is turned off using error_reporting(0); placed at the beginning of wp-config.php file. I tried to put it into the main index.php file as well, to no avail.

The warnings only started to show up today and they don't show up on the live version of the site, which is at least 99% the same code, same database.

Here are the errors (substituted domain name for domain.com):

Warning: is_dir() [function.is-dir]: open_basedir restriction in effect. File(/) is not within the allowed path(s): (/var/www/virtual/domain.com/:/usr/share/php/) in /var/www/virtual/domain.com/htdocs/wp-includes/functions.php on line 2104

Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(/) is not within the allowed path(s): (/var/www/virtual/domain.com/:/usr/share/php/) in /var/www/virtual/domain.com/htdocs/wp-includes/functions.php on line 2095

Warning: is_dir() [function.is-dir]: open_basedir restriction in effect. File(/) is not within the allowed path(s): (/var/www/virtual/domain.com/:/usr/share/php/) in /var/www/virtual/domain.com/htdocs/wp-includes/functions.php on line 2104

Why do I get these messages ? Shouldn't error_reporting(0) turn off all warnings?

4
It should. Either the code that disables it doesn't run, or there is other code that overrides the setting again.Jon
Could you fix the warnings instead? Are you on shared hosting - can open_basedir be turned off?halfer
@ClaudioLudovicoPanetta - there's certainly an argument for disabling on-screen in live, since it creates additional assistance for attackers. But yes, warnings certainly should not be ignored.halfer
The code must run, because it's in wp-config. I checked the theme's function.php file, but there's no error_reporting there. I'd rather not mess with the server config... do you think it's safe to turn it off ? How is it possible that yesterday there were no warnings ?Mariano Grandioso
@halfer preventing error messages from being displayed on-screen should be done by settings the display_errors configuration option.Oswald

4 Answers

2
votes

Try:

ini_set("display_errors", "off");

However, depending on your host you may not have access to dynamically change ini settings like that.

1
votes

Some of the commenters don't seem to know how Wordpress sets error reporting. They say stuff like "should be done" like this, or that. But the fact is in Wordpress all you have to do is go to wp-config.php and change WP_DEBUG from true to false. That will do exactly what you want.

1
votes

OK, so in the end I solved the problem by directly modifying the php.ini file. This is the line:

php_admin_value open_basedir none

Thanks, @halfer

1
votes

In wordpress, one can turn on error reporting with just the following lines of code:

define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors', 0);