diff --git a/plugins/woocommerce/src/Database/Migrations/CustomOrderTable/CLIRunner.php b/plugins/woocommerce/src/Database/Migrations/CustomOrderTable/CLIRunner.php index d9fb98d09be..4a819757010 100644 --- a/plugins/woocommerce/src/Database/Migrations/CustomOrderTable/CLIRunner.php +++ b/plugins/woocommerce/src/Database/Migrations/CustomOrderTable/CLIRunner.php @@ -494,8 +494,7 @@ class CLIRunner { ) ); } else { - // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r -- This is a CLI command and debugging code is intended. - $errors = print_r( $failed_ids, true ); + $errors = wp_json_encode( $failed_ids, JSON_PRETTY_PRINT ); return WP_CLI::error( sprintf( diff --git a/plugins/woocommerce/src/Internal/BatchProcessing/BatchProcessingController.php b/plugins/woocommerce/src/Internal/BatchProcessing/BatchProcessingController.php index 04c3b8a6a36..c9d8a117480 100644 --- a/plugins/woocommerce/src/Internal/BatchProcessing/BatchProcessingController.php +++ b/plugins/woocommerce/src/Internal/BatchProcessing/BatchProcessingController.php @@ -368,13 +368,12 @@ class BatchProcessingController { $batch_detail_string = ''; // Log only first and last, as the entire batch may be too big. if ( count( $batch ) > 0 ) { - // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r -- Logging is for debugging. - $batch_detail_string = '\n' . print_r( + $batch_detail_string = "\n" . wp_json_encode( array( 'batch_start' => $batch[0], 'batch_end' => end( $batch ), ), - true + JSON_PRETTY_PRINT ); } $error_message = "Error processing batch for {$batch_processor->get_name()}: {$error->getMessage()}" . $batch_detail_string; diff --git a/plugins/woocommerce/src/Internal/DataStores/Orders/OrdersTableDataStore.php b/plugins/woocommerce/src/Internal/DataStores/Orders/OrdersTableDataStore.php index 33f3cb2619a..ec3cd2d2c7b 100644 --- a/plugins/woocommerce/src/Internal/DataStores/Orders/OrdersTableDataStore.php +++ b/plugins/woocommerce/src/Internal/DataStores/Orders/OrdersTableDataStore.php @@ -1308,8 +1308,7 @@ WHERE * @return void */ private function log_diff( array $diff ): void { - // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r -- This is a log function. - $this->error_logger->notice( 'Diff found: ' . print_r( $diff, true ) ); + $this->error_logger->notice( 'Diff found: ' . wp_json_encode( $diff, JSON_PRETTY_PRINT ) ); } /**