Skip to content

Commit

Permalink
[PHP 8.4] fputcsv() - The $escape parameter must be provided as its d…
Browse files Browse the repository at this point in the history
…efault 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 <[email protected]>

* PHP CS Fixer - lib/Varien/Io/File.php

---------

Co-authored-by: Sven Reichel <[email protected]>
  • Loading branch information
ADDISON74 and sreichel authored Oct 22, 2024
1 parent b3d67b5 commit 4fdf499
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* @property resource $_fileHandler
* @property string $_delimiter
* @property string $_enclosure
* @property string $_escape
*/
abstract class Mage_ImportExport_Model_Export_Adapter_Abstract
{
Expand Down Expand Up @@ -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;
}
Expand Down
10 changes: 9 additions & 1 deletion app/code/core/Mage/ImportExport/Model/Export/Adapter/Csv.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -109,7 +116,8 @@ public function writeRow(array $rowData)
$this->_fileHandler,
$data,
$this->_delimiter,
$this->_enclosure
$this->_enclosure,
$this->_escape
);

$this->_rowsCount++;
Expand Down
7 changes: 6 additions & 1 deletion lib/Magento/Profiler/Output/Csvfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ class Magento_Profiler_Output_Csvfile extends Magento_Profiler_OutputAbstract
*/
protected $_enclosure;

/**
* @var string
*/
protected $_escape = '\\';

/**
* Start output buffering
*
Expand Down Expand Up @@ -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);
}
}
}

0 comments on commit 4fdf499

Please sign in to comment.