From 4fdf499c2012b0847774f9625b553a9ff6ed0487 Mon Sep 17 00:00:00 2001 From: ADDISON <8360474+ADDISON74@users.noreply.github.com> Date: Tue, 22 Oct 2024 09:35:12 +0300 Subject: [PATCH] [PHP 8.4] fputcsv() - The $escape parameter must be provided as its default value will change (#4298) * fputcsv - lib/Varien/File/Csv.php Deprecated. The PHP default value for the escape parameter is '\\' and I declared it at the beginning in certain files. * fputcsv - lib/Magento/Profiler/Output/Csvfile.php Deprecated. Deprecated. The $escape parameter must be provided as its default value will change. * fputcsv - lib/Varien/Io/File.php Deprecated. The $escape parameter must be provided as its default value will change. * fputcsv - app/code/core/Mage/ImportExport/Model/Export/Adapter/Abstract.php Deprecated. The $escape parameter must be provided as its default value will change. * fputcsv - app/code/core/Mage/ImportExport/Model/Export/Adapter/Csv.php Deprecated. The $escape parameter must be provided as its default value will change. * Revert the changes * escape parameter in function Co-authored-by: Sven Reichel * PHP CS Fixer - lib/Varien/Io/File.php --------- Co-authored-by: Sven Reichel --- .../ImportExport/Model/Export/Adapter/Abstract.php | 3 ++- .../Mage/ImportExport/Model/Export/Adapter/Csv.php | 10 +++++++++- lib/Magento/Profiler/Output/Csvfile.php | 7 ++++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/app/code/core/Mage/ImportExport/Model/Export/Adapter/Abstract.php b/app/code/core/Mage/ImportExport/Model/Export/Adapter/Abstract.php index 4624b7b19a4..0086dbac448 100644 --- a/app/code/core/Mage/ImportExport/Model/Export/Adapter/Abstract.php +++ b/app/code/core/Mage/ImportExport/Model/Export/Adapter/Abstract.php @@ -22,6 +22,7 @@ * @property resource $_fileHandler * @property string $_delimiter * @property string $_enclosure + * @property string $_escape */ abstract class Mage_ImportExport_Model_Export_Adapter_Abstract { @@ -147,7 +148,7 @@ public function setHeaderCols(array $headerCols) foreach ($headerCols as $colName) { $this->_headerCols[$colName] = false; } - fputcsv($this->_fileHandler, array_keys($this->_headerCols), $this->_delimiter, $this->_enclosure); + fputcsv($this->_fileHandler, array_keys($this->_headerCols), $this->_delimiter, $this->_enclosure, $this->_escape); } return $this; } diff --git a/app/code/core/Mage/ImportExport/Model/Export/Adapter/Csv.php b/app/code/core/Mage/ImportExport/Model/Export/Adapter/Csv.php index cb6d77a2ad4..ef86570bf4d 100644 --- a/app/code/core/Mage/ImportExport/Model/Export/Adapter/Csv.php +++ b/app/code/core/Mage/ImportExport/Model/Export/Adapter/Csv.php @@ -38,6 +38,13 @@ class Mage_ImportExport_Model_Export_Adapter_Csv extends Mage_ImportExport_Model */ protected $_enclosure = '"'; + /** + * Field escape character. + * + * @var string + */ + protected $_escape = '\\'; + /** * Source file handler. * @@ -109,7 +116,8 @@ public function writeRow(array $rowData) $this->_fileHandler, $data, $this->_delimiter, - $this->_enclosure + $this->_enclosure, + $this->_escape ); $this->_rowsCount++; diff --git a/lib/Magento/Profiler/Output/Csvfile.php b/lib/Magento/Profiler/Output/Csvfile.php index 1a6a6b87342..4f8fbda69da 100644 --- a/lib/Magento/Profiler/Output/Csvfile.php +++ b/lib/Magento/Profiler/Output/Csvfile.php @@ -33,6 +33,11 @@ class Magento_Profiler_Output_Csvfile extends Magento_Profiler_OutputAbstract */ protected $_enclosure; + /** + * @var string + */ + protected $_escape = '\\'; + /** * Start output buffering * @@ -86,7 +91,7 @@ protected function _writeFileContent($fileHandle) foreach ($this->_getColumns() as $columnId) { $row[] = $this->_renderColumnValue($timerId, $columnId); } - fputcsv($fileHandle, $row, $this->_delimiter, $this->_enclosure); + fputcsv($fileHandle, $row, $this->_delimiter, $this->_enclosure, $this->_escape); } } }