From 2645b3c3923fd6b3560122cadfa3cf949e714a14 Mon Sep 17 00:00:00 2001 From: Samuele Mancuso Date: Mon, 8 Jun 2026 09:44:52 +0200 Subject: [PATCH] fix: provide legacy escape to fputcsv() for PHP 8.4/8.5 PHP 8.4 deprecates calling fputcsv() without an explicit $escape; the default will change in 8.5. Pass the legacy escape ('\\') to all CSV export/import-report writers to keep current behavior and silence the deprecation. --- modules/anagrafiche/bulk.php | 4 ++-- modules/articoli/src/Import/CSV.php | 4 ++-- modules/impianti/src/Import/CSV.php | 4 ++-- modules/liste_newsletter/actions.php | 4 ++-- modules/listini_cliente/src/Import/CSV.php | 4 ++-- src/Importer/CSVImporter.php | 6 +++--- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/modules/anagrafiche/bulk.php b/modules/anagrafiche/bulk.php index c1e1e4fd32..69bad046ea 100755 --- a/modules/anagrafiche/bulk.php +++ b/modules/anagrafiche/bulk.php @@ -176,7 +176,7 @@ $handle = fopen($file, 'w'); // Scrittura dell'intestazione - fputcsv($handle, ['email', 'ragione_sociale', 'fonte', 'sede_referente'], ';'); + fputcsv($handle, ['email', 'ragione_sociale', 'fonte', 'sede_referente'], ';', escape: '\\'); // Scrittura dei dati foreach ($results as $row) { @@ -185,7 +185,7 @@ $row['ragione_sociale'], $row['fonte'], $row['sede_referente'], - ], ';'); + ], ';', escape: '\\'); } fclose($handle); diff --git a/modules/articoli/src/Import/CSV.php b/modules/articoli/src/Import/CSV.php index 19a8d7f41e..6ff1fda984 100644 --- a/modules/articoli/src/Import/CSV.php +++ b/modules/articoli/src/Import/CSV.php @@ -619,12 +619,12 @@ public function saveFailedRecordsWithErrors($filepath) $header = $this->getHeader(); $header[] = 'Errore'; - fputcsv($file, $header, ';'); + fputcsv($file, $header, ';', escape: '\\'); foreach ($this->failed_rows as $index => $row) { $error_message = $this->failed_errors[$index] ?? 'Errore sconosciuto'; $row[] = $error_message; - fputcsv($file, $row, ';'); + fputcsv($file, $row, ';', escape: '\\'); } fclose($file); diff --git a/modules/impianti/src/Import/CSV.php b/modules/impianti/src/Import/CSV.php index 0cb3ec9dc6..5bc5baf266 100644 --- a/modules/impianti/src/Import/CSV.php +++ b/modules/impianti/src/Import/CSV.php @@ -234,12 +234,12 @@ public function saveFailedRecordsWithErrors($filepath) $header = $this->getHeader(); $header[] = 'Errore'; - fputcsv($file, $header, ';'); + fputcsv($file, $header, ';', escape: '\\'); foreach ($this->failed_rows as $index => $row) { $error_message = $this->failed_errors[$index] ?? 'Errore sconosciuto'; $row[] = $error_message; - fputcsv($file, $row, ';'); + fputcsv($file, $row, ';', escape: '\\'); } fclose($file); diff --git a/modules/liste_newsletter/actions.php b/modules/liste_newsletter/actions.php index 3c31b26487..24be08161a 100755 --- a/modules/liste_newsletter/actions.php +++ b/modules/liste_newsletter/actions.php @@ -146,7 +146,7 @@ $handle = fopen($file, 'w'); // Scrittura dell'intestazione - fputcsv($handle, ['Email', 'Ragione sociale'], ';'); + fputcsv($handle, ['Email', 'Ragione sociale'], ';', escape: '\\'); // Scrittura dei dati foreach ($results as $destinatario) { @@ -156,7 +156,7 @@ fputcsv($handle, [ $origine->email, $anagrafica->ragione_sociale, - ], ';'); + ], ';', escape: '\\'); } fclose($handle); diff --git a/modules/listini_cliente/src/Import/CSV.php b/modules/listini_cliente/src/Import/CSV.php index 29336b4218..34393814e8 100644 --- a/modules/listini_cliente/src/Import/CSV.php +++ b/modules/listini_cliente/src/Import/CSV.php @@ -229,12 +229,12 @@ public function saveFailedRecordsWithErrors($filepath) $header = $this->getHeader(); $header[] = 'Errore'; - fputcsv($file, $header, ';'); + fputcsv($file, $header, ';', escape: '\\'); foreach ($this->failed_rows as $index => $row) { $error_message = $this->failed_errors[$index] ?? 'Errore sconosciuto'; $row[] = $error_message; - fputcsv($file, $row, ';'); + fputcsv($file, $row, ';', escape: '\\'); } fclose($file); diff --git a/src/Importer/CSVImporter.php b/src/Importer/CSVImporter.php index b984968699..c94aebd2df 100644 --- a/src/Importer/CSVImporter.php +++ b/src/Importer/CSVImporter.php @@ -224,7 +224,7 @@ public static function createExample($filepath) fprintf($file, chr(0xEF).chr(0xBB).chr(0xBF)); foreach ($content as $row) { - fputcsv($file, $row, ';'); + fputcsv($file, $row, ';', escape: '\\'); } fclose($file); @@ -348,14 +348,14 @@ public function saveFailedRecordsWithErrors($filepath) // Scrivi l'intestazione con colonna errore $header = $this->getHeader(); $header[] = 'Errore'; - fputcsv($file, $header, ';'); + fputcsv($file, $header, ';', escape: '\\'); } // Scrivi le righe fallite con errore foreach ($this->failed_rows as $index => $row) { $error_message = $this->failed_errors[$index] ?? 'Errore sconosciuto'; $row[] = $error_message; - fputcsv($file, $row, ';'); + fputcsv($file, $row, ';', escape: '\\'); } fclose($file);