Post by straightlight » Sun Oct 01, 2017 7:20 pm

Since countless users are not posting their OC version with their error logs, a good solution would be to consider the following addition for the next release.

In system/framework.php file,

find:

Code: Select all

$log->write('PHP ' . $error . ':  ' . $message . ' in ' . $file . ' on line ' . $line);
replace with:

Code: Select all

$log->write('PHP ' . VERSION . ' - ' . $error . ':  ' . $message . ' in ' . $file . ' on line ' . $line);
Also in catalog/controller/startup/error.php file,

replace:

Code: Select all

$this->log->write('PHP ' . $error . ':  ' . $message . ' in ' . $file . ' on line ' . $line);
with:

Code: Select all

$this->log->write('PHP ' . VERSION . ' - ' . $error . ':  ' . $message . ' in ' . $file . ' on line ' . $line);
This tactic would reduce posting and ease troubleshooting on the forum and / or github.
Last edited by straightlight on Sun Oct 01, 2017 8:04 pm, edited 1 time in total.

The most generated errors being found on Opencart forum originates from contributed programming.

Regards,
Straightlight


Guru Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by yodapt » Sun Oct 01, 2017 7:46 pm

I agree with the above.

Opencart Developer - My Extension Showcase
Contact me at aeon.yoda@gmail.com


User avatar
Active Member

Posts

Joined
Fri Jun 17, 2011 6:39 pm


Post by straightlight » Sun Oct 01, 2017 8:29 pm

Another suggestion to improve troubleshooting, as a partial but improved solution, would be to edit the system/engine/action.php file to show the reflection class source from where the error is originating from rather than the destination. Most of the errors on the forum are 99% about contributed codes but it is not possible at this time to see the reflection class.

To improve this, in your system/engine/action.php file,

Find:

Code: Select all

$reflection = new ReflectionClass($class);
Add below:

Code: Select all

$registry->set('reflectionClass', $reflection);
In catalog/controller/startup/error.php file,

find:

Code: Select all

$this->log->write('PHP ' . $error . ':  ' . $message . ' in ' . $file . ' on line ' . $line);
replace with:

Code: Select all

$this->log->write('PHP - Reflection Class: ' . $this->registry->get('reflectionClass)->name . ' - ' . $error . ':  ' . $message . ' in ' . $file . ' on line ' . $line);
Another solution would be by replacing the line above with:

Code: Select all

$this->log->write('PHP - Reflection Class: ' . __METHOD__ . ' - ' . $error . ':  ' . $message . ' in ' . $file . ' on line ' . $line);

The most generated errors being found on Opencart forum originates from contributed programming.

Regards,
Straightlight


Guru Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by daveyoi » Mon Oct 02, 2017 4:40 am

Using PHP 7 goes some way to reducing the confusion as to where errors are happening as every error is an exception with a full stack trace...

We also add https://github.com/filp/whoops to all of our development environments as so to help us step through those traces faster than scanning log files.

Image
Tristar Web Solutions


New member
Online

Posts

Joined
Sun Oct 05, 2014 2:38 am

Post by straightlight » Mon Oct 02, 2017 4:50 am

I found a similar error tracker but a bit more recent as it also allows to integrate the events into logs which Opencart already does: https://github.com/jasny/error-handler . It would be a great tool to have as it is also compatible with PHP 7 as it seem quite easy to use.

In addition, this tool can be combined with other error handlers by using an access token which may be quite practical for the Opencart already implemented API controllers.

The most generated errors being found on Opencart forum originates from contributed programming.

Regards,
Straightlight


Guru Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 7 guests