Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

KissER Error Handling & Debugging [contribution]


FWR Media

Recommended Posts

KissER Error Handling & Debugging

 

a KISS contribution ( Keep It Simple Stupid )

 

Compatibility:

osCommerce ( MS2.2/RC ALL )

PHP5.2+/5.3+ ( PHP 4 NOT supported )

 

Installation:

Simple 2-3 minutes

 

Potential code conflicts:

Effectively none the one exception would be if the tep_db_query() function had been modified for Chemos old query debug.

 

What is it and what will it do for me?

 

Main Benefits:

 


  •  
  • Would you like to be able to find and handle errors that your site is currently hiding/suppressing?
  • Would you like to have a file to check to see if your site has any errors while at the front end the users see nothing?
  • Ever been developing a site and would like to see errors without them breaking up the page?
  • Ever wanted to look for errors but don't want to "turn up" the error reporting because users would see them?
  • Ever wanted to show a new client just how many errors their current osCommerce site has but they can't see?
  • Would you like to stop errors from printing out full paths in view of the hacking world?
  • Would you like to easily be able to debug: queries, variables, arrays, objects or site slowdowns?

 

Gracefull Error Handling:

Disclaimer: Some PHP errors like parse errors and fatal errors can NOT be handled gracefully.

 

osCommerce has nothing in place at all to deal with errors, either you suppress errors ( error_reporting ( E_ALL & ~E_NOTICE ) ) which is the standard osCommerce set up. Or you set error reporting high ( error_reporting ( E_ALL | E_STRICT ) ) and the site falls apart with errors all over the shop. ( obviously not possible on a live site ).

 

Understandably because of this the vast majority of osCommerce installations suppress all errors. What this means is that most osCommerce installations have tons of errors but the owners of the sites are happily ignorant of this fact. You will probably be surprised to know that some shops even suppress warnings, terrible!

 

Also, when errors print to screen via standard PHP error handling they show your servers full path which is a potential serious security risk, KissER suppresses these full paths.

 

There are those ( usually contributors of dodgy contributions or incapable developers ) who would tell you "don't worry about those, they are only notices .. they're fine!", rubbish!, errors are errors and a good shop should have none. An error free shop will be faster, more secure and easier to debug. Ignore errors at your peril!

 

Think your site is error free? I very much doubt it!

 

But the last thing I want my users to see is errors!!

 

Agreed .. which is why KissER Error Handling & Debugging has settings where these errors can be printed to screen but only visible to you, or silently written to an error file where you can view and handle them at your leisure.

 

Debugging:

 

Powerful set of simple to use debugging tools where you can easily debug: -

 


  •  
  • queries
  • variables
  • arrays
  • objects

 

You can also use "break points" to locate where a site is slowing down or breaking.

 

Download the current version

Edited by FWR Media
Link to comment
Share on other sites

Unfortunately, I'm not much of a PHP programmer... so, this may be a dumb question.

 

Is there any way to make this compatable with PHP 4.xx?

 

Thanks!

 

No sorry. I have no interest in supporting PHP 4, it is dead and gone.

Link to comment
Share on other sites

I Robert,

 

Thanks for this awesome contribution, keep up the good work.

In the installation you say for application_top.php file

 

Find ( near the top ) ...
// set the level of error reporting
 error_reporting(E_ALL & ~E_NOTICE);

Replace with ...
// set the level of error reporting
 error_reporting(E_ALL & ~E_NOTICE);

 // KISS Error Handling & Debugging by FWR Media 
 include_once 'includes/kiss_error_handler.php';

I mean, you are saying to replace error_reporting(E_ALL & ~E_NOTICE); with the same code. Is this a bug? Did you want to say something else or it is correct?

Link to comment
Share on other sites

I Robert,

 

Thanks for this awesome contribution, keep up the good work.

In the installation you say for application_top.php file

 

Find ( near the top ) ...
// set the level of error reporting
 error_reporting(E_ALL & ~E_NOTICE);

Replace with ...
// set the level of error reporting
 error_reporting(E_ALL & ~E_NOTICE);

 // KISS Error Handling & Debugging by FWR Media 
 include_once 'includes/kiss_error_handler.php';

I mean, you are saying to replace error_reporting(E_ALL & ~E_NOTICE); with the same code. Is this a bug? Did you want to say something else or it is correct?

 

Hi

 

May look odd but it is correct.

 

I find people make less mistakes when you "replace" code rather than "add above" or "add below".

 

It certainly isn't a bug as it just replaces the same code and adds a bit below.

 

E.g. if you hadn't actually looked at the code you would have simply replaced the one with the other. Had it been an "add below" you would have had to think about it.

Edited by FWR Media
Link to comment
Share on other sites

You are sooooo right..crying.gif

 

I'm now using this contribution and it is very helpful when I try to get rid of all errors, and that's NOT one or two..

I agree... I even found that the total module cash on delevery with fee was not deleting all the keys when pressing the remove module name. I had 2 keys 9 times each in the database...

Link to comment
Share on other sites

Well this is nice early feedback .. seems people are enjoying it or at least finding it useful.

 

What I find with contributions like this and Security Pro is they don't tend to get noticed unless people have problems.

Link to comment
Share on other sites

Is it recommended to remove the install of Chemo's query mod before installing this?

 

Yes, the code in the tep_db_query() function may conflict.

Link to comment
Share on other sites

Hi,

I am testing this contribution and find it very useful. I like your contribs, thanks for that! :)

 

Everything works fine, except this:

 

Error: Undefined index: break

File: includes/kiss_error_handler.php

Line: 316

E_WARNING Error Count: 1

Error: Invalid argument supplied for foreach()

File: includes/kiss_error_handler.php

Line: 316

 

My configuration:

PHP Version 5.2.12

Linux

 

Kind regards

Link to comment
Share on other sites

Hi,

I am testing this contribution and find it very useful. I like your contribs, thanks for that! :)

 

Everything works fine, except this:

 

Error: Undefined index: break

File: includes/kiss_error_handler.php

Line: 316

E_WARNING Error Count: 1

Error: Invalid argument supplied for foreach()

File: includes/kiss_error_handler.php

Line: 316

 

My configuration:

PHP Version 5.2.12

Linux

 

Kind regards

 

Interesting .. KissER reporting itself for errors :rolleyes:

 

catalog/includes/kiss_error_handler.php

 

Line 76 should be ..

 

    private static $breakpoints = array( 'break' => array() );

Link to comment
Share on other sites

I'm getting too much E_NOTICE errors filling up the log-file, so I made a litle switch:

 

On top of catalog/includes/kiss_error_handler.php:

 

define('KISS_ERROR_REPORTING_SKIP', 'E_NOTICE');

 

Around line 279 I have made this changes:

 

if ($error_type <> KISS_ERROR_REPORTING_SKIP) {

$error_string = 'Date / Time: ' . date("d-m-Y H:i:s") . PHP_EOL;

$error_string .= 'Error Type: [' . $error_type . '] ' . $detail['string'] . PHP_EOL;

$error_string .= 'On line ' . $detail['line'] . PHP_EOL . 'File ' . $detail['file'] . PHP_EOL;

$error_string .= str_repeat( '-+', 30 ) . PHP_EOL . PHP_EOL;

$this->writeToFile( $error_string );

}

 

Is this ok, or do you have a better way to do this? (It is working)

Link to comment
Share on other sites

I'm getting too much E_NOTICE errors filling up the log-file, so I made a litle switch:

 

On top of catalog/includes/kiss_error_handler.php:

 

define('KISS_ERROR_REPORTING_SKIP', 'E_NOTICE');

 

Around line 279 I have made this changes:

 

if ($error_type <> KISS_ERROR_REPORTING_SKIP) {

$error_string = 'Date / Time: ' . date("d-m-Y H:i:s") . PHP_EOL;

$error_string .= 'Error Type: [' . $error_type . '] ' . $detail['string'] . PHP_EOL;

$error_string .= 'On line ' . $detail['line'] . PHP_EOL . 'File ' . $detail['file'] . PHP_EOL;

$error_string .= str_repeat( '-+', 30 ) . PHP_EOL . PHP_EOL;

$this->writeToFile( $error_string );

}

 

Is this ok, or do you have a better way to do this? (It is working)

 

If the log file is filling up then you really shouldn't be logging the errors to file. The log file is there for when you are just about error free and you want to find any errors that crop up over time.

 

If you are still working on the errors then use the screen method but remember to set ..

 

KISS_ERROR_REPORTING_GET_SWITCH

 

This way only you will see the errors printed to screen.

Link to comment
Share on other sites

Hi Rob

 

Great Contrib !! And thanks for sharing.

 

But should I really go through and fix all undefined variable errors? most people just knock down the reporting level to ignore these?

 

cheers

 

rhys

 

Errors are errors. You are right, most people just knock down the error reporting "what I can't see can't hurt me", this is a very bad practice, errors should never be ignored.

 

Error free sites are more secure, easier to debug and faster. Undefined variables show shoddy coding and are a route to hacking.

Link to comment
Share on other sites

I hope that this is not a dumb request.... but, what the heck - I have to admit to not being very bright when it comes to this...

 

I have installed this contribution and it has already helped me quite a bit. However, right now I am trying to determine logical errors. For example, I am tring to install paypal IPN and the orders are double posting on my orders table. With this, I am trying to see exactly which module is processing a given query (i.e. is it happening in checkout_confirmation.php, orders.php, general.php, etc.). I can see that all of these queries are occuring, but I'm having difficulty zeroing in on my culprit modules.

 

Is it possible to add a line that would show the calling module (and ideally the line) where things are happening? If so, can you give me some idea of how to do it?

 

Thanks!

 

 

Link to comment
Share on other sites

I hope that this is not a dumb request.... but, what the heck - I have to admit to not being very bright when it comes to this...

 

I have installed this contribution and it has already helped me quite a bit. However, right now I am trying to determine logical errors. For example, I am tring to install paypal IPN and the orders are double posting on my orders table. With this, I am trying to see exactly which module is processing a given query (i.e. is it happening in checkout_confirmation.php, orders.php, general.php, etc.). I can see that all of these queries are occuring, but I'm having difficulty zeroing in on my culprit modules.

 

Is it possible to add a line that would show the calling module (and ideally the line) where things are happening? If so, can you give me some idea of how to do it?

 

Thanks!

 

This is where you can use the "break points" add breakpoints to the files in question and see at which points these queries occur.

Link to comment
Share on other sites

  • 4 weeks later...

Hello, Quick question, When I installed this contribution, I get only blank pages. Doesnt seem to matter what I set the handler thing to.

 

EDIT: Ok just tell me this if my host is still using php 4.4.9 will this program work?

Edited by deaconest
Link to comment
Share on other sites

Hello, Quick question, When I installed this contribution, I get only blank pages. Doesnt seem to matter what I set the handler thing to.

 

EDIT: Ok just tell me this if my host is still using php 4.4.9 will this program work?

 

Not a hope.

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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...