Logging: Ensure filtered log messages don't persist across multiple log handlers (#48336)
Log messages can be modified via the `woocommerce_logger_log_message` filter hook on a per-handler basis, but if the message is modified for the first handler, the subsequent handlers were receiving the modified message instead of the original. This simply ensures each handler receives the original message instead. Fixes #47126
This commit is contained in:
parent
d63da14787
commit
dc5ad32fb7
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: fix
|
||||
|
||||
Ensure data filtered by `woocommerce_logger_log_message` does not carry across multiple log handlers
|
|
@ -183,10 +183,10 @@ class WC_Logger implements WC_Logger_Interface {
|
|||
* @param array $context Additional information for log handlers.
|
||||
* @param object $handler The handler object, such as WC_Log_Handler_File. Available since 5.3.
|
||||
*/
|
||||
$message = apply_filters( 'woocommerce_logger_log_message', $message, $level, $context, $handler );
|
||||
$filtered_message = apply_filters( 'woocommerce_logger_log_message', $message, $level, $context, $handler );
|
||||
|
||||
if ( null !== $message ) {
|
||||
$handler->handle( $timestamp, $level, $message, $context );
|
||||
if ( null !== $filtered_message ) {
|
||||
$handler->handle( $timestamp, $level, $filtered_message, $context );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue