2023-02-19, 03:33 PM
Because PHP 8 elevated many Notices to Warnings and it is desirable to improve the codebase to eliminate warnings and even with 1833 the error log now gets filled with such things like
Rather than try to manually create warnings, I am logging them on my production forum, thereby letting my members travel the forum doing what they normally do. It is useful to read the error log without having to convert unix epoch time to help locate the event that caused the warning.
A core edit will add an extra human-readable line to the error log message.
The error log entry is defined in lines 375 through 383 of inc/class_error.php
Change
Essentially, add two variable definitions, change the dateline data and add an additional datetime line to $error_data.
Now the above error message is easier to read with the added line.
<datetime>2023-02-19 14:59:37 UTC</datetime>
<error>
<dateline>1676818777</dateline>
<script>search.php</script>
<line>476</line>
<type>2</type>
<friendly_type>Warning</friendly_type>
<message>Undefined array key "lastread"</message>
<back_trace>#0 errorHandler->error() called at [/inc/class_error.php:153]
#1 errorHandler->error_callback() called at [/search.php:476]
</back_trace>
</error>
Rather than try to manually create warnings, I am logging them on my production forum, thereby letting my members travel the forum doing what they normally do. It is useful to read the error log without having to convert unix epoch time to help locate the event that caused the warning.
A core edit will add an extra human-readable line to the error log message.
The error log entry is defined in lines 375 through 383 of inc/class_error.php
Change
$error_data = "<error>\n";
$error_data .= "\t<dateline>".TIME_NOW."</dateline>\n";
$error_data .= "\t<script>".$file."</script>\n";
$error_data .= "\t<line>".$line."</line>\n";
$error_data .= "\t<type>".$type."</type>\n";
$error_data .= "\t<friendly_type>".$this->error_types[$type]."</friendly_type>\n";
$error_data .= "\t<message>".$message."</message>\n";
$error_data .= $back_trace;
$error_data .= "</error>\n\n";
to $dl = TIME_NOW;
$dt = date('Y-m-d H:i:s T', $dl);
$error_data = "<error>\n";
$error_data .= "\t<dateline>".$dl."</dateline>\n";
$error_data .= "\t<datetime>".$dt."</datetime>\n";
$error_data .= "\t<script>".$file."</script>\n";
$error_data .= "\t<line>".$line."</line>\n";
$error_data .= "\t<type>".$type."</type>\n";
$error_data .= "\t<friendly_type>".$this->error_types[$type]."</friendly_type>\n";
$error_data .= "\t<message>".$message."</message>\n";
$error_data .= $back_trace;
$error_data .= "</error>\n\n";
Essentially, add two variable definitions, change the dateline data and add an additional datetime line to $error_data.
Now the above error message is easier to read with the added line.
<datetime>2023-02-19 14:59:37 UTC</datetime>