Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

KissER Error Handling & Debugging [contribution]


FWR Media

Recommended Posts

Ok I tested it and it works fine.

 

Well if you definately changed the KissER code to: -

 

<div style="padding: 3em; font-family: verdana; width: 750px; margin-left: auto; margin-right: auto; clear: both;">

Adding the clear:both

 

Then you must have template code that uses ob_start to buffer the output in which case i can't help..

Link to comment
Share on other sites

About the template, I have the original one from the osc 2.3.1, but modified with jquery.

Maybe here I send you the kiss_error_handler fiel to check, because this file : ob_start I don't have:

 

 

<?php

/**

*

* KissER Error Handling & Debugging

* KISS = (Keep It Simple Stupid!)

*

* @package KissER Error Handling & Debugging v1.0

* @@licensed2kill http://www.opensource.org/licenses/gpl-2.0.php GNU Public License

* @@Link http://www.fwrmedia.co.uk

* @@copyright Copyright 2008-2009 FWR Media

* @@author Robert Fisher, FWR Media, http://www.fwrmedia.co.uk

* @lastdev $Author:: Rob $: Author of last commit

* @lastmod $Date:: 2010-01-28 14:40:31 +0000 (Thu, 28 Jan 2010) $: Date of last commit

* @version $Rev:: 20 $: Revision of last commit

* @Id $Id:: kiss_error_handler.php 20 2010-01-28 14:40:31Z Rob $: Full Details

*/

 

/**

* User Main Settings

*/

define( 'KISS_ERROR_REPORTING_OUTPUT', 'file' ); // string - screen ( prints to screen ) / suppress ( suppresses errors ) / file ( saves errors to file ).

define( 'KISS_ERROR_REPORTING_SWITCH', 'on' ); // string - on / off ( off will default back to standard PHP error reporting.

/**

* KISS_ERROR_REPORTING_GET_SWITCH is to protect a live site from showing errors to screen but still can be seen on screen by the developer

* KISS_ERROR_REPORTING_GET_SWITCH only applies when KISS_ERROR_REPORTING_OUTPUT is set to screen

* If KISS_ERROR_REPORTING_GET_SWITCH is set as 'false' errors and all other output will always be printed to screen.

* If KISS_ERROR_REPORTING_GET_SWITCH is set anything other than 'false', ( e.g. fwroutput ) output to screen will only occur if the value is in the querystring as a key

* e.g. www.mysite.com/index.php?fwroutput

*/

define( 'KISS_ERROR_REPORTING_GET_SWITCH', 'false' ); // string - false - user setting - see above comments

 

/**

* Extra Settings

*/

define( 'KISS_ERROR_REPORTING_SUPPRESS_DUPLICATES', 'on' ); // string - on / off ( "on" will stop the repeated output of errors already printed )

/**

* Query Debugging

*/

define( 'KISS_ERROR_REPORTING_QUERIES', 'on' ); // string - on / off ( will output all queries and query times )

/**

* Using Break Points

*/

define( 'KISS_ERROR_REPORTING_BREAKPOINTS', 'on' ); // string - on / off ( will output all breakpoint times and current errors )

// End user settings

 

/**

* Set our own error handling system instead of PHP

*/

set_error_handler( 'kiss_error_handler' );

 

/**

* kiss_error_handler() takes over the handling of standard PHP errors.

*

* @@param int $errno - error number

* @@param string $errstr - the error as a descriptive string

* @@param string $errfile - file where the error originated

* @@param mixed $errline - the line in the file where the error originated

*/

function kiss_error_handler( $errno, $errstr, $errfile, $errline ) {

if ( !defined( 'KISS_ERROR_REPORTING_SWITCH' ) || ( strtolower( KISS_ERROR_REPORTING_SWITCH ) != 'on' ) ) {

// Will default back to standard PHP error reporting.

return false;

}

KissER::i( $errno, $errstr, $errfile, $errline );

} // end function

 

/**

* Error handling class

*/

final class KissER {

 

private static $_singleton;

private $errorfile_path;

private $error_file = 'kiss_errors.txt';

private static $registry = array( 'errors' => array() );

private static $breakpoints = array();

private static $queries = array();

private static $reporting = 'file';

private static $rootpath;

private static $error_types = array( E_USER_ERROR => 'E_USER_ERROR', E_USER_WARNING => 'E_USER_WARNING',

E_USER_NOTICE => 'E_USER_NOTICE', E_WARNING => 'E_WARNING',

E_NOTICE => 'E_NOTICE', E_ERROR => 'E_ERROR',

E_STRICT => 'E_STRICT' );

private $use_htmlentities = true; // Convert screen output to html entities

 

/**

* Constructor attempts to create kiss_errors.txt

* @see makeErrorsFile()

*/

private function __construct() {

self::$rootpath = str_replace( 'includes', '', str_replace( DIRECTORY_SEPARATOR, '/', realpath( dirname( __FILE__ ) ) ) );

$this->makeErrorsFile();

} // end constructor

 

/**

* Create a singleton instance of the class.

* Attaches the current error to the registry

*

* @@param int $errno - error number

* @@param string $errstr - the error as a descriptive string

* @@param string $errfile - file where the error originated

* @@param mixed $errline - the line in the file where the error originated

* @return KISS_Error_Handler

*/

public static function i( $errno, $errstr, $errfile, $errline ) {

if ( false === is_object( self::$_singleton ) ) {

self::$_singleton = new self;

self::$reporting = strtolower( KISS_ERROR_REPORTING_OUTPUT );

self::registryAttach( $errno, $errstr, $errfile, $errline );

return self::$_singleton;

}

self::registryAttach( $errno, $errstr, $errfile, $errline );

return self::$_singleton;

} // end method

 

public static function q( $time, $query ) {

if ( false === is_object( self::$_singleton ) ) {

self::$_singleton = new self;

self::$reporting = strtolower( KISS_ERROR_REPORTING_OUTPUT );

self::logQuery( $time, $query );

return self::$_singleton;

}

self::logQuery( $time, $query );

return self::$_singleton;

} // end method

 

public static function breakpoint( $time, $file, $line, $exit_script = false ) {

if ( false === is_object( self::$_singleton ) ) {

self::$_singleton = new self;

self::$reporting = strtolower( KISS_ERROR_REPORTING_OUTPUT );

self::setBreakPoint( $time, $file, $line, $exit_script );

return self::$_singleton;

}

self::setBreakPoint( $time, $file, $line, $exit_script );

return self::$_singleton;

} // end method

 

private static function stripRootPath( $full_file_path ) {

return str_replace( self::$rootpath, '', str_replace( DIRECTORY_SEPARATOR, '/', $full_file_path ) );

}

 

/**

* Handles errors on class destruction

*/

public function __destruct() {

$this->outputBreakPoints();

$this->outputQueries();

$this->manage();

} // end destructor

 

/**

* Attempt to create the errorfile.txt

*/

private function makeErrorsFile() {

 

$this->errorfile_path = self::$rootpath . 'errors/';

if ( false === is_writable( $this->errorfile_path ) ) {

return trigger_error( 'Class: ' . __CLASS__ . '<br /> Function: ' . __FUNCTION__ . ' errors directory is not writeable.', E_USER_WARNING );

}

if ( is_writable( $this->errorfile_path . $this->error_file ) ) {

return;

}

if ( false === ( $handle = @fopen( $this->errorfile_path . $this->error_file, 'a' ) ) ) {

return trigger_error( 'Class: ' . __CLASS__ . '<br /> Function: ' . __FUNCTION__ . ' cannot open ' . $this->error_file, E_USER_WARNING );

}

fclose( $handle );

} // end method

 

/**

* The registry retains all errors up until they are output on class destruct

*

* @@param int $errno - error number

* @@param string $errstr - the error as a descriptive string

* @@param string $errfile - file where the error originated

* @@param mixed $errline - the line in the file where the error originated

*/

private static function registryAttach( $errno, $errstr, $errfile, $errline ) {

self::$registry['errors'][$errno][] = array( 'type' => self::$error_types[$errno],

'string' => $errstr,

'file' => $errfile,

'line' => $errline );

} // end method

 

/**

* Error output factory

*/

private function manage() {

switch ( self::$reporting ) {

case 'screen':

if ( ( KISS_ERROR_REPORTING_GET_SWITCH == 'false' ) || ( array_key_exists( KISS_ERROR_REPORTING_GET_SWITCH, $_GET ) ) ) {

$this->toScreen();

}

break;

case 'suppress':

return false;

break;

default:

$this->toFile();

break;

}

} // end method

 

private function outputHtmlTop( $title ) {

?>

<div style="padding: 3em; font-family: verdana; width: 750px; margin-left: auto; margin-right: auto; clear: both;">

<div style="width: 100%; background-color: #ffffdd; border: 1px solid #1659AC; font-size: 10pt;">

<div style="background-color: #2E8FCA; font-size: 12pt; font-weight: bold; padding: 0.5em; color: #00598E;">

<div style="float: right; color: #0073BA; font-weight: bold; font-size: 16pt; margin-top: -0.2em;">FWR MEDIA</div>

<?php echo $title . PHP_EOL; ?>

</div>

<?php

}

 

private function outputHtmlBottom() {

?>

</div>

</div>

<?php

}

 

/**

* Output the error registry to screen

*/

private function toScreen() {

$this->outputHtmlTop( 'KissER Error Handling:' );

foreach ( self::$registry['errors'] as $error_code => $errors_array ) {

if ( false === isset( self::$error_types[$error_code] ) ) {

$error_type = 'Unique error code: ' . $error_code;

} else {

$error_type = self::$error_types[$error_code];

}

?>

<div style="padding: 0.5em; background-color: #B3D6EC; color: #00598E; font-weight: bold; font-size: 10pt;"><?php echo $error_type . ' Error Count: ' . count( self::$registry['errors'][$error_code] ); ?></div>

<?php

$already_reported = array();

foreach ( $errors_array as $index => $detail ) {

$detail['file'] = self::stripRootPath( $detail['file'] );

if ( is_array( $detail['string'] ) || is_object( $detail['string'] ) ) {

$detail['string'] = '<pre>' . print_r( $detail['string'], true ) . '</pre>';

} elseif ( false !== $this->use_htmlentities ) {

$detail['string'] = htmlentities( html_entity_decode( $detail['string'] ) );

}

if ( false === array_key_exists( md5( $detail['file'] . $detail['line'] . $detail['string'] ) , $already_reported ) ) {

if ( defined( 'KISS_ERROR_REPORTING_SUPPRESS_DUPLICATES' ) && strtolower( KISS_ERROR_REPORTING_SUPPRESS_DUPLICATES ) == 'on' ) {

$already_reported[md5( $detail['file'] . $detail['line'] . $detail['string'] )] = 1;

}

?>

<div style="padding: 0.5em; background-color: #E0E0E0; color: #027AC6; font-size: 10pt;">Error: <?php echo $detail['string']; ?></div>

<div style="padding: 0.5em; background-color: #E8E8E8; color: #027AC6; font-size: 10pt;">File: <?php echo $detail['file']; ?></div>

<div style="border-bottom: 1px solid #2E8FCA; padding: 0.5em; background-color: #F0F0F0; color: #027AC6; font-size: 10pt;">Line: <?php echo $detail['line']; ?></div>

<?php

}

}

}

$this->outputHtmlBottom();

} // end method

 

/**

* Output the error registry to file

*/

private function toFile() {

foreach ( self::$registry['errors'] as $error_code => $errors_array ) {

if ( false === isset( self::$error_types[$error_code] ) ) {

$error_type = 'Unique error code: ' . $error_code;

} else {

$error_type = self::$error_types[$error_code];

}

$already_reported = array();

foreach ( $errors_array as $index => $detail ) {

$detail['file'] = self::stripRootPath( $detail['file'] );

if ( is_array( $detail['string'] ) || is_object( $detail['string'] ) ) {

$detail['string'] = print_r( $detail['string'], true );

}

if ( false === array_key_exists( md5( $detail['file'] . $detail['line'] . $detail['string'] ) , $already_reported ) ) {

if ( defined( 'KISS_ERROR_REPORTING_SUPPRESS_DUPLICATES' ) && strtolower( KISS_ERROR_REPORTING_SUPPRESS_DUPLICATES ) == 'on' ) {

$already_reported[md5( $detail['file'] . $detail['line'] . $detail['string'] )] = 1;

}

$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 );

}

}

}

} // end method

 

private function outputQueries() {

if ( ( KISS_ERROR_REPORTING_GET_SWITCH == 'false' ) || ( array_key_exists( KISS_ERROR_REPORTING_GET_SWITCH, $_GET ) ) ) {

if ( ( strtolower( KISS_ERROR_REPORTING_QUERIES ) != 'on' ) || ( strtolower( KISS_ERROR_REPORTING_OUTPUT ) != 'screen' ) ) {

return false;

}

$this->outputHtmlTop( 'KissER Query Output:' );

?>

<div style="padding: 0.5em; background-color: #fff; color: #027AC6; font-size: 10pt;"><b>Total Queries:</b> <?php echo self::$queries['count']; ?></div>

<div style="padding: 0.5em; background-color: #fff; color: #027AC6; font-size: 10pt;"><b>Slowest Query Number</b> <?php echo self::$queries['slowest']['count']; ?><br /><b>Time:</b> <?php echo self::$queries['slowest']['time']; ?> Seconds.</div>

<div style="padding: 0.5em; background-color: #fff; color: #027AC6; font-size: 10pt;"><b>Total query Time</b> <?php echo self::$queries['total_time']; ?> Seconds.</div>

<?php

foreach ( self::$queries['queries'] as $index => $detail ) {

?>

<div style="padding: 0.5em; background-color: #E0E0E0; color: #027AC6; font-size: 10pt;">Number: <?php echo $index; ?></div>

<div style="padding: 0.5em; background-color: #E8E8E8; color: #027AC6; font-size: 10pt;">Time: <?php echo $detail['time']; ?> Seconds.</div>

<div style="border-bottom: 1px solid #2E8FCA; padding: 0.5em; background-color: #F0F0F0; color: #027AC6; font-size: 10pt;">Query: <?php echo $detail['query']; ?></div>

<?php

}

$this->outputHtmlBottom();

}

}

 

private function outputBreakPoints() {

if ( ( KISS_ERROR_REPORTING_GET_SWITCH == 'false' ) || ( array_key_exists( KISS_ERROR_REPORTING_GET_SWITCH, $_GET ) ) ) {

if ( ( strtolower( KISS_ERROR_REPORTING_BREAKPOINTS ) != 'on' ) || ( strtolower( KISS_ERROR_REPORTING_OUTPUT ) != 'screen' ) ) {

return false;

}

$this->outputHtmlTop( 'KissER Break Points:' );

foreach ( self::$breakpoints['break'] as $index => $detail ) {

?>

<div style="padding: 0.5em; background-color: #E0E0E0; color: #027AC6; font-size: 10pt;"><b>Number:</b> <?php echo ( $index +1 ); ?> <b>Exit script:</b> <?php echo $detail['exit_script']; ?></div>

<div style="padding: 0.5em; background-color: #E8E8E8; color: #027AC6; font-size: 10pt;"><b>File:</b> <?php echo $detail['file']; ?> <b>Line:</b> <?php echo $detail['line']; ?></div>

<div style="border-bottom: 1px solid #2E8FCA; padding: 0.5em; background-color: #F0F0F0; color: #027AC6; font-size: 10pt;"><b>Seconds:</b> <?php echo $detail['seconds']; ?> <b>Queries:</b> <?php echo $detail['queries']; ?> <b>Errors:</b> <?php echo $detail['errors']; ?></div>

<?php

}

$this->outputHtmlBottom();

}

}

 

/**

* Write to the error file.txt

*

* @@param string $error_string - the error details

*/

private function writeToFile( $error_string ) {

if ( false === ( ( strlen( $error_string ) > 0 ) && @file_put_contents( $this->errorfile_path . $this->error_file, $error_string, FILE_APPEND ) ) ) {

return false;

}

return true;

} // end method

 

private static function logQuery( $time, $query ) {

if ( strtolower( KISS_ERROR_REPORTING_QUERIES ) != 'on' ) {

return false;

}

if ( !array_key_exists( 'count', self::$queries ) ) {

self::$queries['count'] = 0;

self::$queries['slowest'] = array( 'count' => 0, 'time' => 0 );

self::$queries['total_time'] = 0;

}

self::$queries['count'] ++;

self::$queries['total_time'] += $time;

if ( self::$queries['slowest']['time'] < $time ) {

self::$queries['slowest'] = array( 'count' => self::$queries['count'], 'time' => $time );

}

self::$queries['queries'][self::$queries['count']] = array( 'query' => preg_replace( array( "@[\n\t]+@", "@[\s]+@" ), array( '', ' ' ), $query ),

'time' => $time );

} // end methods

 

private static function setBreakPoint( $time, $file, $line, $exit_script ) {

if ( strtolower( KISS_ERROR_REPORTING_BREAKPOINTS ) != 'on' ) {

return;

}

$queries = 0;

if ( isset( self::$queries['queries'] ) && !empty( self::$queries['queries'] ) ) {

$queries = count( self::$queries['queries'] ) -1;

}

if ( false === isset( self::$breakpoints['start_time'] ) ) {

self::$breakpoints['start_time'] = $time;

$time = 0.00;

} else {

$time = round( ( $time - self::$breakpoints['start_time'] ), 4 );

}

self::$breakpoints['break'][] = array( 'seconds' => $time,

'file' => self::stripRootPath( $file ),

'line' => $line,

'queries' => $queries,

'errors' => self::breakpointsGetErrors(),

'exit_script' => ( ( false === $exit_script ) ? 'false' : 'true' ) );

if ( false !== $exit_script ) {

session_write_close();

exit;

}

} // end method

 

private static function breakpointsGetErrors() {

if ( empty( self::$registry['errors'] ) ) {

return 'No errors recorded';

}

$bp_errors = array();

foreach ( self::$registry['errors'] as $error_code => $errors_array ) {

$bp_errors[self::$error_types[$error_code]] = count( self::$registry['errors'][$error_code] );

}

$br_error_string = '';

foreach ( $bp_errors as $type => $count ) {

$br_error_string .= $type . ': ('. $bp_errors[$type] . ') ';

}

return trim( $br_error_string );

} // End method

 

} // end class

?>

Link to comment
Share on other sites

define( 'KISS_ERROR_REPORTING_OUTPUT', 'file' );

 

Needs to be screen to print to screen

Link to comment
Share on other sites

Done but still nothing. I think I will uninstall this add on and then install it again. Wich version do I have to install on my osc 2.3.1?

A other possibility I think is not availible

Link to comment
Share on other sites

Done but still nothing. I think I will uninstall this add on and then install it again. Wich version do I have to install on my osc 2.3.1?

A other possibility I think is not availible

 

Use the latest but add clear:both as you did before ( the osCommerce template doesn't clear its floats ) .. no idea why you can't get screen output .. must be a template/css thing local to your site code.

Edited by FWR Media
Link to comment
Share on other sites

  • 2 weeks later...

Hello. After installation all I'm getting is this error:

Content Encoding Error

 

The page you are trying to view cannot be shown because it uses an invalid or unsupported form of compression.

 

Please contact the website owners to inform them of this problem.

Any help will be appreciated. Thanks.

Link to comment
Share on other sites

@@Irin

 

Sounds like you have installed incorrectly .. this is generating errors and gzip compression is set to on in admin therefore you are getting compression errors.

 

Check you have a decent version of PHP too ( 5.2+ )

Link to comment
Share on other sites

@@Irin

 

Sounds like you have installed incorrectly .. this is generating errors and gzip compression is set to on in admin therefore you are getting compression errors.

 

Check you have a decent version of PHP too ( 5.2+ )

Yes, I had my gzip compression set to on at Compression Level 5. As soon as I turned it off, it worked. So, I guess gzip compression can't work together with error handling module. It's either one or the other. Well... good to know.

 

Thanks, Robert.

Link to comment
Share on other sites

  • 3 months later...

This is the only error that is being reported. I am sure it is probably something I have done. using oscommerce 2.3.3

line is if( $PHP_SELF == 'index.php' && $cPath == '' ) {

 

Error Type: [E_NOTICE] Undefined variable: cPath

On line 34

File includes/modules/front_page/heading_title.php

Thanks Robert in advance

Link to comment
Share on other sites

You are using an old version of Modular Front Page, or you have made changes to that module. Download the latest version and replace the Heading Title module.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

  • 5 months later...

This is a splendid contribution which I wish I had installed previously.

 

I'm not sure if this is quite the right place to ask this, but I would be grateful for advice. I am working on moving to 2.3.3 and have a basic version augmented by PayPal Website Payments Pro Hosted Solution (Official) (http://addons.oscommerce.com/info/8481) as being the PCI compliant solution. The only other addition is KissER.

 

The following line in the paypal checkout code on the page that drags in the paypal iframe is being flagged as an error by KissER as follows - Error: Undefined index: error

 

if(!$HTTP_GET_VARS['error'] == true){

// if the customer is not logged on, redirect them to the login page

if (!tep_session_is_registered('customer_id')) {

$navigation->set_snapshot(array('mode' => 'SSL', 'page' => FILENAME_CHECKOUT_PAYMENT));

tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));

}

 

Is this poor coding by Paypal or is it somehow connected with changing the error handling with KissER? Has anyone got an idea on what it should be?

Link to comment
Share on other sites

That's poor coding. Change the first line of that code to:

 

if( isset( $HTTP_GET_VARS['error'] ) && $HTTP_GET_VARS['error'] != true ) {

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...

I delayed installing this contribution because I thought it would be too technical for me. I have to say, this is one of the BEST contributions for OSC. Thanks guys.

osCommerce: made for programmers, ...because store owners do not want to be programmers.

https://trends.google.com/trends/explore?date=all&amp;geo=US&amp;q=oscommerce

Link to comment
Share on other sites

  • 1 month later...

Hi @@FWR Media, I used this wonderful addon with great success when updating from 2.2 to 2.3.3. It help tremendously... Especially for a newbie like myself.

 

I was wondering if you are going to update this addon for 2.3.3.2?

 

I notice this function in includes/functions/database.php

 

  function tep_db_query($query, $link = 'db_link') { 
   global $$link; 

   if (defined('STORE_DB_TRANSACTIONS') && (STORE_DB_TRANSACTIONS == 'true')) { 
     error_log('QUERY ' . $query . "\n", 3, STORE_PAGE_PARSE_TIME_LOG); 
   } 
   $start_time = microtime( true ); 
   $result = mysql_query($query, $$link) or tep_db_error($query, mysql_errno(), mysql_error()); 
   if ( class_exists( 'KissER' ) ) { 
     KissER::q( round( ( microtime( true ) - $start_time ), 4 ), $query ); 
   } 
   if (defined('STORE_DB_TRANSACTIONS') && (STORE_DB_TRANSACTIONS == 'true')) { 
      $result_error = mysql_error(); 
      error_log('RESULT ' . $result . ' ' . $result_error . "\n", 3, STORE_PAGE_PARSE_TIME_LOG); 
   } 

   return $result; 
 } 

 

got changed to mysqli in 2.3.3.2. Will your function still work (with everything else updated to 2.3.3.2), at least until php 5.4?

 

Not a big deal for me... I have done most, for now, all my troubleshooting. And I'm sure there will be a bunch more addon's that will require updating (I'm sure us newbie will have to get used to it).

 

 

Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...

I am using a brand new, fresh out of the box, just broke the seal version of 2.3.3.4. KissER Error Handling & Debugging is the only contrib I have attempted to install. Once everything is uploaded and the files are edited, this is the error I get:

 

http://img200.imageshack.us/img200/2913/ha14.jpg

 

I sure hope FWR is still supporting this contrib.

Edited by Snarg
Link to comment
Share on other sites

@@Snarg I'm not sure... but I don't think FWR is around these forums much. That said, this is an awesome addon, but needs to be updated to work with 2.3.3.2 or above.

 

You can try this yourself, by changing out all occurrences of mysql to tep_db or mysqli. Like this (I have not tried this... so don't forget to backup!!!);

 

  function tep_db_query($query, $link = 'db_link') { 
   global $$link; 

   if (defined('STORE_DB_TRANSACTIONS') && (STORE_DB_TRANSACTIONS == 'true')) { 
     error_log('QUERY ' . $query . "\n", 3, STORE_PAGE_PARSE_TIME_LOG); 
   } 
   $start_time = microtime( true ); 
   $result = mysql_query($query, $$link) or tep_db_error($query, mysql_errno(), mysql_error()); 
   if ( class_exists( 'KissER' ) ) { 
     KissER::q( round( ( microtime( true ) - $start_time ), 4 ), $query ); 
   } 
   if (defined('STORE_DB_TRANSACTIONS') && (STORE_DB_TRANSACTIONS == 'true')) { 
      $result_error = mysql_error(); 
      error_log('RESULT ' . $result . ' ' . $result_error . "\n", 3, STORE_PAGE_PARSE_TIME_LOG); 
   } 

   return $result; 
 } 

 

to

 function tep_db_query($query, $link = 'db_link') { 
   global $$link; 

   if (defined('STORE_DB_TRANSACTIONS') && (STORE_DB_TRANSACTIONS == 'true')) { 
     error_log('QUERY ' . $query . "\n", 3, STORE_PAGE_PARSE_TIME_LOG); 
   } 
   $start_time = microtime( true ); 
   $result = tep_db_query($query, $$link) or tep_db_error($query, mysqli_errno(), mysqli_error()); 
   if ( class_exists( 'KissER' ) ) { 
     KissER::q( round( ( microtime( true ) - $start_time ), 4 ), $query ); 
   } 
   if (defined('STORE_DB_TRANSACTIONS') && (STORE_DB_TRANSACTIONS == 'true')) { 
      $result_error = tep_db_error(); 
      error_log('RESULT ' . $result . ' ' . $result_error . "\n", 3, STORE_PAGE_PARSE_TIME_LOG); 
   } 

   return $result; 
 } 

 

Hopefully someone with more experience than I can confirm.

Link to comment
Share on other sites

@@Snarg I got this working in 2.3.3.4. In includes/functions/database.php around line 51 find

 

$result = mysqli_query($$link, $query) or tep_db_error($query, mysqli_errno($$link), mysqli_error($$link));

 

and change to

 

  $start_time = microtime( true );
 $result = mysqli_query($$link, $query) or tep_db_error($query, mysqli_errno($$link), mysqli_error($$link));
  if ( class_exists( 'KissER' ) ) { 
     KissER::q( round( ( microtime( true ) - $start_time ), 4 ), $query ); 
   } 

 

Again, I have not tested this thoroughly. However tried it and it seems to be working...

 

Link to comment
Share on other sites

@@Snarg I got this working in 2.3.3.4. In includes/functions/database.php around line 51 find

 

$result = mysqli_query($$link, $query) or tep_db_error($query, mysqli_errno($$link), mysqli_error($$link));

 

and change to

 

 $start_time = microtime( true );
$result = mysqli_query($$link, $query) or tep_db_error($query, mysqli_errno($$link), mysqli_error($$link));
if ( class_exists( 'KissER' ) ) {
KissER::q( round( ( microtime( true ) - $start_time ), 4 ), $query );
} 

 

Again, I have not tested this thoroughly. However tried it and it seems to be working...

So far it looks good. Now I just need to have an error so I can see if it actually reports. Thank you @@greasemonkey :)

Link to comment
Share on other sites

  • 11 months later...

I have installed this addon on oscommerce 2.3.4
It is working perfectly
I am new to KISS Error reporting
But please could you help me figure out how to debug  a particular URL like below

any special code of the KISSerror contribution to be added to shopping_cart.php......

............../shopping_cart.php?products_id=1906{2}83{13}144{14}145{23}119{38}250{43}343{36}241{50}430{51}450&action=remove_product

Awaiting an earliest response...

Edited by radhavallabh
Link to comment
Share on other sites

  • 8 months later...

For 2.3.4 users:

 

This should work in includes/functions/database.php:

 

-snip-

 

  function tep_db_query($query, $link = 'db_link') {
    global $$link;

    if (defined('STORE_DB_TRANSACTIONS') && (STORE_DB_TRANSACTIONS == 'true')) {
      error_log('QUERY ' . $query . "\n", 3, STORE_PAGE_PARSE_TIME_LOG);
    }
    $start_time = microtime( true );
    $result = mysqli_query($$link, $query) or tep_db_error($query, mysqli_errno($$link), mysqli_error($$link));
    if ( class_exists( 'KissER' ) ) {
      KissER::q( round( ( microtime( true ) - $start_time ), 4 ), $query );
    }
    if (defined('STORE_DB_TRANSACTIONS') && (STORE_DB_TRANSACTIONS == 'true')) {
       $result_error = mysqli_error();
       error_log('RESULT ' . $result . ' ' . $result_error . "\n", 3, STORE_PAGE_PARSE_TIME_LOG);
    }

    return $result;
  }

 

-snip-

 

regards,

stefan

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...