From 96aba0a64a85227703ea79cfd1846a0c662aeac1 Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Fri, 14 Oct 2022 06:18:34 +0200 Subject: fix invalid dates causing a null dereference error --- Vote.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Vote.php') diff --git a/Vote.php b/Vote.php index 4f74e15..8265604 100644 --- a/Vote.php +++ b/Vote.php @@ -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) { -- cgit v1.2.3