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

TrackChange doesn't handle all return types of \DateTime::createFromFormat(...) #1584

Merged
merged 3 commits into from Feb 23, 2019
Merged

Conversation

superhaggis
Copy link
Contributor

Description

DateTime::createFromFormat(...) returns either a \DateTime instance or FALSE, not NULL. Working on the basis that there might be legitimate TrackChange constructor calls containing a NULL date parameter, line 67 has been expanded to check not only for NOT NULL but also NOT FALSE.

Without this additional check, a document with "Track Changes" enabled could cause an Exception to be raised when loaded into a reader.

"Exception: DateTime::__construct(): Failed to parse time string (@) at position 0 (@): Unexpected character"

I couldn't see any relevant documentation that would benefit from being updated with details of this change, hence the incomplete checklist.

Fixes # N/A

Checklist:

  • I have run composer run-script check --timeout=0 and no errors were reported
  • The new code is covered by unit tests (check build/coverage for coverage report)
  • I have updated the documentation to describe the changes

DateTime::createFromFormat(...) returns either a \DateTime instance or FALSE, not NULL.  Working on the basis that there might be legitimate TrackChange constructor calls containing a NULL date parameter, line 67 has been expanded to check not only for NOT NULL but also NOT FALSE.

Without this additional check, a document with "Track Changes" enabled could cause an Exception to be raised when loaded into a reader.

"Exception: DateTime::__construct(): Failed to parse time string (@) at position 0 (@): Unexpected character"
@coveralls
Copy link

Coverage Status

Coverage remained the same at 94.624% when pulling 2a1870a on superhaggis:patch-1 into 0a73bfd on PHPOffice:develop.

@troosan troosan added this to the v0.17.0 milestone Feb 23, 2019
@troosan troosan self-assigned this Feb 23, 2019
@troosan troosan merged commit 81a1b2a into PHPOffice:develop Feb 23, 2019
mikehudson pushed a commit to mikehudson/PHPWord that referenced this pull request Apr 16, 2019
…ormat(...) (PHPOffice#1584)

* Added boolean check before setting the date
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants