Avoid exception when serializing context

Fixes #32576
This commit is contained in:
David Marín 2022-04-12 07:48:11 +02:00 committed by David Marín
parent 2a74c4d82f
commit eac68cdf50
1 changed files with 5 additions and 1 deletions

View File

@ -78,7 +78,11 @@ class WC_Log_Handler_DB extends WC_Log_Handler {
); );
if ( ! empty( $context ) ) { if ( ! empty( $context ) ) {
try {
$insert['context'] = serialize( $context ); // @codingStandardsIgnoreLine. $insert['context'] = serialize( $context ); // @codingStandardsIgnoreLine.
} catch ( Exception $e ) {
$insert['context'] = 'There was an error while serializing the context: ' . $e->getMessage();
}
} }
return false !== $wpdb->insert( "{$wpdb->prefix}woocommerce_log", $insert, $format ); return false !== $wpdb->insert( "{$wpdb->prefix}woocommerce_log", $insert, $format );