diff options
author | Martin Fischer <martin@push-f.com> | 2022-10-14 06:18:34 +0200 |
---|---|---|
committer | Martin Fischer <martin@push-f.com> | 2022-10-14 06:19:11 +0200 |
commit | 96aba0a64a85227703ea79cfd1846a0c662aeac1 (patch) | |
tree | a7115d5acde41bd67fc2ba274a9b3277b2711499 /Vote.php | |
parent | 63056af6b39e8c58f5faebaa46532e0d86b29ad7 (diff) |
fix invalid dates causing a null dereference error
Diffstat (limited to 'Vote.php')
-rw-r--r-- | Vote.php | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -183,10 +183,11 @@ class VoteHooks { private static function parseVote($line) { $date = DateTime::createFromFormat('Y-m-d H:i', substr($line, 0, strlen('2022-10-03 10:00'))); $parts = explode(' ', substr($line, strlen('2022-10-03 10:00 ')), 3); - $user = Title::newFromText('User:' . rtrim(array_shift($parts), ':')); + $userTitle = Title::newFromText('User:' . rtrim(array_shift($parts), ':')); + $user = $userTitle ? $userTitle->getText() : null; $vote = strtolower(array_shift($parts)); $comment = array_shift($parts); - return ['date' => $date, 'userTitle' => $user, 'user' => $user->getText(), 'vote' => $vote, 'comment' => $comment]; + return ['date' => $date, 'userTitle' => $userTitle, 'user' => $user, 'vote' => $vote, 'comment' => $comment]; } private static function votingFormHtml($parser, $votes) { |