Skip to content

Commit ebc893c

Browse files
authored
Added boolean check before setting the date
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"
1 parent 0a73bfd commit ebc893c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/PhpWord/Element/TrackChange.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ class TrackChange extends AbstractContainer
5858
*
5959
* @param string $changeType
6060
* @param string $author
61-
* @param null|int|\DateTime $date
61+
* @param null|int|bool|\DateTime $date
6262
*/
6363
public function __construct($changeType = null, $author = null, $date = null)
6464
{
6565
$this->changeType = $changeType;
6666
$this->author = $author;
67-
if ($date !== null) {
67+
if ($date !== null && $date !== false) {
6868
$this->date = ($date instanceof \DateTime) ? $date : new \DateTime('@' . $date);
6969
}
7070
}

0 commit comments

Comments
 (0)