diff --git a/includes/admin/class-wc-admin-status.php b/includes/admin/class-wc-admin-status.php index e5f4abfebf8..5be05ea25f9 100644 --- a/includes/admin/class-wc-admin-status.php +++ b/includes/admin/class-wc-admin-status.php @@ -162,7 +162,7 @@ class WC_Admin_Status { * @return string */ public static function get_log_file_handle( $filename ) { - return substr( $filename, 0, strlen( $filename ) > 37 ? strlen( $filename ) - 37 : strlen( $filename ) - 4 ); + return substr( $filename, 0, strlen( $filename ) > 48 ? strlen( $filename ) - 48 : strlen( $filename ) - 4 ); } /** diff --git a/includes/admin/views/html-admin-page-status-logs.php b/includes/admin/views/html-admin-page-status-logs.php index f122087346f..6f501191c00 100644 --- a/includes/admin/views/html-admin-page-status-logs.php +++ b/includes/admin/views/html-admin-page-status-logs.php @@ -15,8 +15,8 @@ if ( ! defined( 'ABSPATH' ) ) {

- - + +

diff --git a/includes/log-handlers/class-wc-log-handler-file.php b/includes/log-handlers/class-wc-log-handler-file.php index 04d26f6b051..0b233ef4a92 100644 --- a/includes/log-handlers/class-wc-log-handler-file.php +++ b/includes/log-handlers/class-wc-log-handler-file.php @@ -248,16 +248,14 @@ class WC_Log_Handler_File extends WC_Log_Handler { */ public function remove( $handle ) { $removed = false; - $file = self::get_log_file_path( $handle ); - + $file = trailingslashit( WC_LOG_DIR ) . $handle; if ( $file ) { if ( is_file( $file ) && is_writable( $file ) ) { // phpcs:ignore WordPress.VIP.FileSystemWritesDisallow.file_ops_is_writable - $this->close( $handle ); // Close first to be certain no processes keep it alive after it is unlinked. + $this->close( $file ); // Close first to be certain no processes keep it alive after it is unlinked. $removed = unlink( $file ); // phpcs:ignore WordPress.VIP.FileSystemWritesDisallow.file_ops_unlink } do_action( 'woocommerce_log_remove', $handle, $removed ); } - return $removed; } diff --git a/tests/unit-tests/log/log-handler-file.php b/tests/unit-tests/log/log-handler-file.php index 5e64a2aafc0..17a68b2170f 100644 --- a/tests/unit-tests/log/log-handler-file.php +++ b/tests/unit-tests/log/log-handler-file.php @@ -75,7 +75,7 @@ class WC_Tests_Log_Handler_File extends WC_Unit_Test_Case { $handler = new WC_Log_Handler_File(); $log_name = '_test_remove'; $handler->handle( time(), 'debug', 'debug', array( 'source' => $log_name ) ); - $handler->remove( $log_name ); + $handler->remove( wc_get_log_file_name( $log_name ) ); $this->assertFileNotExists( WC_Log_Handler_File::get_log_file_path( $log_name ) ); }