Turning off error logging in 2.64

12 posts by 2 authors in: Forums > CMS Builder
Last Post: March 31, 2015   (RSS)

Hi All,

Probably missed it, but now that there's global error logging, which is a really time saving great addition, is there a way to turn off error report logging as well as the visible reports in V2.64?

That way we can work on errors that are not critical on our own time frame without building up large amounts of error report records for our clients to worry over.

And while you're updating for the next go around, is there a way that you can change the "sorry there are no records" message, to something like "Congratulations, you have no errors"? (just for this section...)

Thanks,

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By Dave - March 17, 2015

Hi Jerry, 

You can prevent errors from being displayed on web pages with this setting:
Admin > General Settings > Security Settings > Hide PHP Errors [x] Hide all PHP errors and warnings (still logged to error log)

However, there's no way to disable logging of errors, which actually include notices, warnings and other diagnostic messages.  The error log will, however, only store the last (approximately) 1000 error messages.  

As far as how to explain this to your clients.  I'd just acknowledge that there is, in fact, an error log accessible to admin users under the admin menu.  That it's purpose is to provide diagnostic data to developers and programmers.  And that it can be safely ignored.

Most of the software used in building websites maintains "error" logs of various sorts, include the webserver (Apache error logs), mysql, etc.  Even every windows computer has an "event log" full of "errors".

When building new websites, I'd recommend avoid writing code that produces php warnings/notices/etc just because it will make it easier to spot actual errors in the log.  But for existing websites, I wouldn't bother with making any changes unless you're updating the website anyway.  One last point on that is that PHP adds and removes warnings and notices about various things in between the difference versions.  Sometimes even outputting a warning with a new release only to hide it later.  It's really just a diagnostic log for developers, clients don't need to worry about it.

Hope that helps, let me know any questions or if there's any remaining issues that this doesn't address.

PS: If you have the email notification feature on and it's emailing them, just edit the error notification email template under Admin > Email Templates and set the To: address to your own email.

Dave Edis - Senior Developer
interactivetools.com

Hi Dave,

Unfortunately, some 'Clients' don't always understand the valid concepts that you described, and some of those can get either extremely nervous, or decide use it as a wedge to use in negotiating their (financial) position I.E.: No final payment until all the errors go away, etc.). 

Up to now, clients would have had to hunt  for most error logs (until the excellent addition in 2.64)

Before writing this post, I tried the,"Don't show this section on the menu bar" option, but that unfortunately doesn't hide the log from displaying in the admin section (in scary bright red, so client's can't miss it).

I don't want to disable this extremely useful feature, but I'd really prefer an option that hides the error log from being seen by anyone, including in the admin menu area.

Any thoughts?

Thanks,

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By Dave - March 17, 2015

Hi Jerry, 

Ok, I got it.  That's unfortunate as catering to their requests to not show diagnostic logs will increase your cost of supporting them with their web requests.  In any case... 

You can disable error logging like this: 

- Edit /lib/menus/errorlog_functions.php
- Comment out this line at the top (add code in red): 

// enable error logging
//errorlog_enable();

This will prevent all errors from being logged and prevent any error log emails from being sent.

Note that these changes will get overwritten with an upgrade.

Hope that helps, let me know any other questions.

Dave Edis - Senior Developer
interactivetools.com

Thanks, Dave,

So I  guess there's no way to make the "don't show in menus" checkbox include the admin area?

That way the errors would get logged (as they should) and if a developer admin was aware of  the switch and wanted to view the errors to fix them, they could.

They just wouldn't always be a red flag in the client's face.

Best,

Jerry

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By Dave - March 17, 2015

Hi Jerry, 

Do you want to send me an email with login details and I can take a look at what the specific errors are?  You may be able to hide them by adding @ in a few places (which suppresses errors).

I could give you a line of code to add if you wanted to hide the menu on a specific install.  But it's still direct linked from a few places in the admin.  

Another option would be to not give the clients access to the admin menu.  

Can you email me details to dave@interactivetools.com so I can have a look?  

Thanks!

Dave Edis - Senior Developer
interactivetools.com

By gkornbluth - March 18, 2015 - edited: March 18, 2015

Thank you Dave...

I've started a page about fixing PHP errors in the CMSB Cookbook,( http://www.thecmsbcookbook.com ) and will include anything that gets posted here.

Best,

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Hi All,

I’ve come up with a few PHP errors that I’m not sure how to suppress.

I’m guessing that adding an @ before $fieldname, in:   

if (!array_key_exists($fieldname, $CURRENT_USER)

might be the correct fix, but I wanted to check, just in case.

________________________________

The errors are:

E_NOTICE: Undefined index: approved (line 29)  in the line $wasChecked
E_NOTICE: Undefined index: last_name (line 33) inside $message=<<< __TEXT__
E_NOTICE: Undefined index: first_name (line 33)


In the emailOnApproved plugin below:

<?php
/*
Plugin Name: Email On Approved
Description: Email the user their password once they are approved
Version: 1.00
Requires at least: 2.04
*/


// UPDATE THESE VALUES

// DON'T UPDATE ANYTHING BELOW THIS LINE

addAction('record_postsave',  'emailOnApproved_sendPassword', null, 4);


//
function emailOnApproved_sendPassword($tableName, $isNewRecord, $oldRecord, $recordNum) {
  global $CURRENT_USER, $SETTINGS;
  $fieldname = 'approved';

  // error checking
    if ($tableName != 'accounts') { return; }
  if (!array_key_exists($fieldname, $CURRENT_USER)) {
    die(__FUNCTION__ .": You must create an accounts fields called '$fieldname'!");
  }

  // send email
  $wasChecked   = intval(!$oldRecord[$fieldname] && $_REQUEST[$fieldname]);
  $wasUnchecked = intval($oldRecord[$fieldname]  && !$_REQUEST[$fieldname]);

$message=<<< __TEXT__
    Welcome {$_REQUEST['first_name']} {$_REQUEST['last_name']},<br><br>
 
Your membership has been  processed successfully and you now have access to the Members Only area of our web site. <br> <br>
Your user name is: {$_REQUEST['username']} <br>
and your login password is: XXXXXX<br><br>

Once you have successfully logged in, you must change your password and can then update your own profile information. <br><br>
 
 
<a href="http://www.nawafl.com{$GLOBALS['WEBSITE_LOGIN_LOGIN_FORM_URL']}">Click here to login</a> <br><br>
 
Best, <br>  <br>
    
The Membership Committee  
__TEXT__;


$headers  = 'MIME-Version: 1.0' . "\r\n";  
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";  
$headers .="FROM:". $SETTINGS['adminEmail'];  
 
   if ($wasChecked) {
    $errors = mail($_REQUEST['email'],"Your membership has been successfully processed!",$message,$headers);  
    if ($errors!=1) { die("Mail Error: $php_errormsg"); }
  }
 
}
 
?>

Thanks,

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By Dave - March 30, 2015

Hi Jerry, 

Try these patches:

  // send email
  $wasChecked   = intval(!$oldRecord[$fieldname] && @$_REQUEST[$fieldname]);
  $wasUnchecked = intval($oldRecord[$fieldname]  && !@$_REQUEST[$fieldname]);

And for the first/last name, that actually indicates a possible error.  You may not want to send an email if the user hasn't filled out the form completely.  It's giving an error because it expects a field that isn't define even with a blank value.  So it's useful to know.

In any case, you can't use @ inside heredoc (http://php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc) strings but you can force them to have defined values just above it:

$_REQUEST['first_name'] = @$_REQUEST['first_name']; 
$_REQUEST['last_name']  = @$_REQUEST['last_name']; 

$message=<<< __TEXT__
Welcome {$_REQUEST['first_name']} {$_REQUEST['last_name']},<br><br>

 Hope that helps!

Dave Edis - Senior Developer
interactivetools.com