Skip to content

Commit 4fdf499

Browse files
addison74sreichel
andauthored
[PHP 8.4] fputcsv() - The $escape parameter must be provided as its default value will change (OpenMage#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 <[email protected]> * PHP CS Fixer - lib/Varien/Io/File.php --------- Co-authored-by: Sven Reichel <[email protected]>
1 parent b3d67b5 commit 4fdf499

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

app/code/core/Mage/ImportExport/Model/Export/Adapter/Abstract.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
* @property resource $_fileHandler
2323
* @property string $_delimiter
2424
* @property string $_enclosure
25+
* @property string $_escape
2526
*/
2627
abstract class Mage_ImportExport_Model_Export_Adapter_Abstract
2728
{
@@ -147,7 +148,7 @@ public function setHeaderCols(array $headerCols)
147148
foreach ($headerCols as $colName) {
148149
$this->_headerCols[$colName] = false;
149150
}
150-
fputcsv($this->_fileHandler, array_keys($this->_headerCols), $this->_delimiter, $this->_enclosure);
151+
fputcsv($this->_fileHandler, array_keys($this->_headerCols), $this->_delimiter, $this->_enclosure, $this->_escape);
151152
}
152153
return $this;
153154
}

app/code/core/Mage/ImportExport/Model/Export/Adapter/Csv.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ class Mage_ImportExport_Model_Export_Adapter_Csv extends Mage_ImportExport_Model
3838
*/
3939
protected $_enclosure = '"';
4040

41+
/**
42+
* Field escape character.
43+
*
44+
* @var string
45+
*/
46+
protected $_escape = '\\';
47+
4148
/**
4249
* Source file handler.
4350
*
@@ -109,7 +116,8 @@ public function writeRow(array $rowData)
109116
$this->_fileHandler,
110117
$data,
111118
$this->_delimiter,
112-
$this->_enclosure
119+
$this->_enclosure,
120+
$this->_escape
113121
);
114122

115123
$this->_rowsCount++;

lib/Magento/Profiler/Output/Csvfile.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ class Magento_Profiler_Output_Csvfile extends Magento_Profiler_OutputAbstract
3333
*/
3434
protected $_enclosure;
3535

36+
/**
37+
* @var string
38+
*/
39+
protected $_escape = '\\';
40+
3641
/**
3742
* Start output buffering
3843
*
@@ -86,7 +91,7 @@ protected function _writeFileContent($fileHandle)
8691
foreach ($this->_getColumns() as $columnId) {
8792
$row[] = $this->_renderColumnValue($timerId, $columnId);
8893
}
89-
fputcsv($fileHandle, $row, $this->_delimiter, $this->_enclosure);
94+
fputcsv($fileHandle, $row, $this->_delimiter, $this->_enclosure, $this->_escape);
9095
}
9196
}
9297
}

0 commit comments

Comments
 (0)