Jump to content

Log php errors and not display them


stormy

Recommended Posts

I've run into an interesting problem with the "Display errors" setting in General Settings > Other.

 

My server is configured to not display errors and log them to an error log, which I think is the only sane choice :)

 

However, WHMCS doesn't log errors. The "Display errors" setting overrides everything:

 

  • If I turn it on, errors are displayed to users, and logged. This means any PHP error will show and totally break the site. Not a good idea.

  • If I turn it off, errors are not displayed NOR logged to the error_log. Not a good idea either.

 

No matter what my php.ini settings are, and no matter what I specify via .htaccess, this setting overrides it all.

 

Has anybody succeeded in overriding this?

 

This is from WHMCS support:

"If Display errors is enabled it will run:

error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED ^ E_WARNING);

If Display errors isn't enabled it will run:

error_reporting(0);"

 

With the normal php error settings this will display on the screen, to have this log to a file this would require adjusting your php configuration settings (This isn't something we can support as we are not system administrators)

 

I pointed out that this can't be done, and I was told to put in a feature request :(

Link to comment
Share on other sites

  • 7 months later...
  • 1 year later...

Just a quick question here if perhaps someone can answer it... I'd really appreciate it.

 

I turned on Display Errors today through WHMCS Admin - General Settings/Other and when I hit Submit, suddenly the whole site became the display of one error. Now I can't see any page on the site - all you see is this one error message. Prior to this, the site worked fine.

 

I went into the database through phpmyadmin and changed "DisplayErrors" from 'on' to 'off' in the tblconfiguration table. But when I did that - now any page on the site says it can't load because there are too many redirect loops!

 

When I turn "DisplayErrors" back to 'on' in the whmcs database, it goes back to displaying the one error... but still no site.

 

Does anyone have any idea how I can turn Display Errors back off in a way that will make the site visible again?

 

Thanks so much!

Edited by jcncnc
Link to comment
Share on other sites

  • 10 months later...
Turns out there is a solution. You can create a hook that enables error reporting:

 

<?php
ini_set("error_reporting", E_ALL & ~E_NOTICE & ~E_DEPRECATED);
ini_set("log_errors", 1);
?>

But then the question is in which hook it should be set (it works only till the end of the script in which the hook is executed). If in all of them, the activity log grows just too quick.

 

Our solution is to create custom public_html/init.php file which looks like the following:

<?php

require_once 'init_real.php';

require_once 'error_logging.php';

 

where init_real.php is the original WHMCS init.php file and error_logging.php looks like this:

 

<?php

 

require_once 'error_logging_level.php';

ini_set("error_reporting", ERROR_LOGGING_LEVEL);

ini_set("log_errors", 1);

 

and of course error_logging_level which might be different in production and development environment:

 

DEVELOPMENT:

<?php

define('ERROR_LOGGING_LEVEL', E_ALL);

 

PRODUCTION:

<?php

define('ERROR_LOGGING_LEVEL', E_ALL & ~E_NOTICE & ~E_STRICT);

 

This is only a temporary solution. Hopefully WHMCS will come up with some better way of handling error logging.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated