Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: issue #1476 crash with numeric string value terminating with new line #1481

Merged
merged 5 commits into from
May 23, 2020

Conversation

giannign1
Copy link
Contributor

@giannign1 giannign1 commented May 20, 2020

This is:

- [ X ] a bugfix
- [ ] a new feature

Checklist:

Why this change is needed?

$worksheet->setCellValueByColumnAndRow(1,1,"123456\n");
Should add the value "123456\n" to the cell at indexes 1,1 but crashes because the DefaultValueBinder::dataTypeForValue matches (with the preg_match case) the value as a DataType::TYPE_NUMERIC and then the Cell->setValueExplicit crashes during the check if (is_string($pValue) && !is_numeric($pValue))

--
Thanks to Vagir-dev for help

Resolves #1476

@giannign1 giannign1 marked this pull request as ready for review May 20, 2020 20:42
@Vagir-dev
Copy link
Contributor

Hi again :)

By the way, it is useful to mention related issues in the PR, like sescribed here.

@giannign1
Copy link
Contributor Author

its mentioned in the title

maybe i did it wrong, sorry, this is the forst time for me

@Vagir-dev
Copy link
Contributor

its mentioned in the title

Just read this article.

maybe i did it wrong, sorry, this is the forst time for me

That's why I gave you the hint ;)

@giannign1
Copy link
Contributor Author

giannign1 commented May 20, 2020

Thank you!
(tha manual way doesn't work for me :/ i used the automatic way)

@Vagir-dev
Copy link
Contributor

I see you did all right! :) 👍

@MarkBaker
Copy link
Member

Thank you for providing the PR to resolve this issue.
Would it be possible to provide a unit test to "prove" the fix?

@MarkBaker
Copy link
Member

Thanks

@MarkBaker MarkBaker merged commit 7b1957f into PHPOffice:master May 23, 2020
PowerKiKi added a commit that referenced this pull request May 31, 2020
### Added

- Support writing to streams in all writers [#1292](#1292)
- Support CSV files with data wrapping a lot of lines [#1468](#1468)
- Support protection of worksheet by a specific hash algorithm [#1485](#1485)

### Fixed

- Fix Chart samples by updating chart parameter from 0 to DataSeries::EMPTY_AS_GAP [#1448](#1448)
- Fix return type in docblock for the Cells::get() [#1398](#1398)
- Fix RATE, PRICE, XIRR, and XNPV Functions [#1456](#1456)
- Save Excel 2010+ functions properly in XLSX [#1461](#1461)
- Several improvements in HTML writer [#1464](#1464)
- Fix incorrect behaviour when saving XLSX file with drawings [#1462](#1462),
- Fix Crash while trying setting a cell the value "123456\n" [#1476](#1481)
- Improved DATEDIF() function and reduced errors for Y and YM units [#1466](#1466)
- Stricter typing for mergeCells [#1494](#1494)

### Changed

- Drop support for PHP 7.1, according to https://phpspreadsheet.readthedocs.io/en/latest/#php-version-support
- Drop partial migration tool in favor of complete migration via RectorPHP [#1445](#1445)
- Limit composer package to `src/` [#1424](#1424)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Crash while trying setting a cell the value "123456\n"
3 participants