Commit f2994fe489c for woocommerce

commit f2994fe489c6ff14fdf39bad02cb59fe5821dd72
Author: Peter Petrov <peter.petrov89@gmail.com>
Date:   Tue Jul 14 16:08:45 2026 +0300

    Fix PHP warning when generating a CSV product export file (#66585)

    * Fix PHP warning when generating a CSV product export file

    * Add changelog entry for CSV export warning fix

diff --git a/plugins/woocommerce/changelog/fix-44784-csv-export-unlink-warning b/plugins/woocommerce/changelog/fix-44784-csv-export-unlink-warning
new file mode 100644
index 00000000000..22749ba7f9a
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-44784-csv-export-unlink-warning
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Fix a PHP warning raised on the first step of every CSV product export.
diff --git a/plugins/woocommerce/includes/export/abstract-wc-csv-batch-exporter.php b/plugins/woocommerce/includes/export/abstract-wc-csv-batch-exporter.php
index 73fd268af66..7c7680333b9 100644
--- a/plugins/woocommerce/includes/export/abstract-wc-csv-batch-exporter.php
+++ b/plugins/woocommerce/includes/export/abstract-wc-csv-batch-exporter.php
@@ -109,7 +109,9 @@ abstract class WC_CSV_Batch_Exporter extends WC_CSV_Exporter {
 	 */
 	public function generate_file() {
 		if ( 1 === $this->get_page() ) {
-			@unlink( $this->get_file_path() ); // phpcs:ignore WordPress.VIP.FileSystemWritesDisallow.file_ops_unlink, Generic.PHP.NoSilencedErrors.Discouraged,
+			if ( file_exists( $this->get_file_path() ) ) {
+				wp_delete_file( $this->get_file_path() );
+			}

 			// We need to initialize the file here.
 			$this->get_file();