Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master-2.21'
Browse files Browse the repository at this point in the history
  • Loading branch information
dregad committed May 5, 2019
2 parents 56b86c9 + 1c1ffd3 commit 47c14c9
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions core/logging_api.php
Expand Up @@ -107,12 +107,16 @@ function log_event( $p_level, $p_msg ) {
break;
case 'file':
if( isset( $t_modifiers ) ) {
# Detect if the log file is writable; if not, issue a one-time warning
static $s_log_writable = null;
if( $s_log_writable === null ) {
$s_log_writable = is_writable( $t_modifiers );

if( $s_log_writable ) {
error_log( $t_php_event . PHP_EOL, 3, $t_modifiers );
} elseif( $s_log_writable === null ) {
# Try to log the event, suppress errors in case the file is not writable
$s_log_writable = @error_log( $t_php_event . PHP_EOL, 3, $t_modifiers );

if( !$s_log_writable ) {
# Display warning message and write it in PHP system log as well.
# Display a one-time warning message and write it to PHP system log as well.
# Note: to ensure the error is shown regardless of $g_display_error settings,
# we manually set the message and log it with error_log_delayed(), which will
# cause it to be displayed at page bottom.
Expand All @@ -122,9 +126,6 @@ function log_event( $p_level, $p_msg ) {
error_log( 'MantisBT - ' . htmlspecialchars_decode( $t_message ) );
}
}
if( $s_log_writable ) {
error_log( $t_php_event . PHP_EOL, 3, $t_modifiers );
}
}
break;
case 'page':
Expand Down Expand Up @@ -368,4 +369,4 @@ function log_get_caller( $p_level = null ) {
$t_caller = $t_caller_plugin . $t_caller_file . ':' . $t_caller_line . ' '
. $t_caller_class . $t_caller_function;
return $t_caller;
}
}

0 comments on commit 47c14c9

Please sign in to comment.