Topic: Error Reporting Not Showing Backtrace in PHP 8.1 +

In PHP 7.4 it gives error like this

DATABASE ERROR : The sales area could not be updated error code : 1054 error message : Unknown column 'descriptio' in 'field list' sql that failed was : UPDATE 0_areas SET descriptio='Global' WHERE area_code = '1' /home/sites/39b/7/7d21587bd2/public_html/dev/includes/errors.inc:235: trigger_error('DATABASE ERROR : The sales area could not be updated error code : 1054 error message : Unknown column 'descriptio' in 'field list' sql that failed was : UPDATE 0_areas SET descriptio='Global' WHERE area_code = '1' ','256') /home/sites/39b/7/7d21587bd2/public_html/dev/includes/errors.inc:261: display_db_error('The sales area could not be updated','UPDATE 0_areas SET descriptio='Global' WHERE area_code = '1'','') /home/sites/39b/7/7d21587bd2/public_html/dev/includes/db/connect_db_mysqli.inc:103: check_db_error('The sales area could not be updated','UPDATE 0_areas SET descriptio='Global' WHERE area_code = '1'','1') /home/sites/39b/7/7d21587bd2/public_html/dev/sales/includes/db/sales_groups_db.inc:71: db_query('UPDATE 0_areas SET descriptio='Global' WHERE area_code = '1'','The sales area could not be updated') /home/sites/39b/7/7d21587bd2/public_html/dev/sales/manage/sales_areas.php:38: update_sales_area('1','Global')

but in php 8.1+ it does not show Backtrace

Unhandled exception [1054]: Unknown column 'descriptio' in 'field list'. in file: /home/sites/39b/7/7d21587bd2/public_html/dev/includes/db/connect_db_mysqli.inc at line 80 exception_handler((mysqli_sql_exception Object))

How to Fix?

www.boxygen.pk

Re: Error Reporting Not Showing Backtrace in PHP 8.1 +

This is not helpful for Debugging the problem because it is not pin pointing the file from where the problem is aroused.

www.boxygen.pk

Re: Error Reporting Not Showing Backtrace in PHP 8.1 +

Adding Comparative Bug Display for PHP 7.4 vs PHP 8.1+

https://postimg.cc/HrzNvY5K/b73f5e8d

www.boxygen.pk

Re: Error Reporting Not Showing Backtrace in PHP 8.1 +

Somehow I got some solution by Changing some lines in the function exception_handler()
Whole function is mentioned below

function exception_handler($exception)
{
    $trace = $exception->getTrace();
    $str_trace = "";
    foreach ($trace as $line){
        $str_trace .= $line['file']." at Line ".$line['line'] . "<br>";
    }

    error_handler(
        E_ERROR,
        sprintf(_("Unhandled exception [%s]: %s. %s."), $exception->getCode(), $exception->getMessage(), $str_trace),
        $exception->getFile(),
        $exception->getLine()
    );
    end_page();
}
www.boxygen.pk