[wp-hackers] DEBUG config and blocking notices
Jeremy Clarke
jer at simianuprising.com
Mon Jul 19 18:56:28 UTC 2010
On Fri, Jul 16, 2010 at 11:07 AM, scribu <scribu at gmail.com> wrote:
> On Fri, Jul 16, 2010 at 6:04 PM, Andrew Gray <andrew at graymerica.com>
> wrote:
>
> > Does anyone have a good solutions to have wordpress only show fatal
> errors
> > and not show Notices when I turn the wp-config DEBUG variable on.
>
> Well, you could use PHP's error_reporting() function directly.
>
> Also, adding ini_set('display_errors', true); is usually enough.
>
>
I agree with scribu. If you don't want notices then you shouldn't be using
WP_DEBUG. It seems to have been designed to be as hardcore as possbile, and
by using notices it enforces strict programming practices that PHP by
default doesn't dictate. If you just want fatal errors to show on the screen
you should turn them on directly in wp-config, the following works for me:
ini_set('display_errors', 1);
error_reporting (E_ALL);
ini_set('display_startup_errors','1');
You can change E_ALL depending on the level you want.
IMHO developing with WP_DEBUG on is a good idea because if you don't then if
someone runs your code with WP_DEBUG they will not be able to use their
site, and will have to fix all the notices first. Speficially, running
WP_DEBUG is pretty much mandatory for any core development because all the
core devs have it turned on, and any notices screw up execution and fill the
output with errors. The main problem with WP_DEBUG is all the notices
generated by plugins that you didn't write (and all the time you spend
emaling plugin authors with ridiculously simple patches they could use to
fix their plugins).
Writing your own code to not generate notices is easy and good for business
in all kinds of ways. The process of declaring/checking your variables
before use leads you to avoid a lot of mysterious and rare bugs down the
line, and helps you clean up your code in the process.
--
Jeremy Clarke
Code and Design | globalvoicesonline.org
More information about the wp-hackers
mailing list