Product import: Remove line breaks in keys (#35880)

* Product import: Remove line breaks in keys

Remove line breaks in keys, to avoid mismatch mapping of keys.

* Fix syntax

* PHPCS

* Changelog.

Co-authored-by: barryhughes <3594411+barryhughes@users.noreply.github.com>
This commit is contained in:
Nico Mollet 2022-12-13 01:21:13 +01:00 committed by GitHub
parent 6fe4afad14
commit f4032654a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
When importing product CSV, ensure line breaks within header columns do not break the import process.

View File

@ -79,6 +79,9 @@ class WC_Product_CSV_Importer extends WC_Product_Importer {
if ( false !== $handle ) {
$this->raw_keys = version_compare( PHP_VERSION, '5.3', '>=' ) ? array_map( 'trim', fgetcsv( $handle, 0, $this->params['delimiter'], $this->params['enclosure'], $this->params['escape'] ) ) : array_map( 'trim', fgetcsv( $handle, 0, $this->params['delimiter'], $this->params['enclosure'] ) ); // @codingStandardsIgnoreLine
// Remove line breaks in keys, to avoid mismatch mapping of keys.
$this->raw_keys = wc_clean( wp_unslash( $this->raw_keys ) );
// Remove BOM signature from the first item.
if ( isset( $this->raw_keys[0] ) ) {
$this->raw_keys[0] = $this->remove_utf8_bom( $this->raw_keys[0] );