summaryrefslogtreecommitdiff
path: root/Vote.php
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2022-10-14 06:18:34 +0200
committerMartin Fischer <martin@push-f.com>2022-10-14 06:19:11 +0200
commit96aba0a64a85227703ea79cfd1846a0c662aeac1 (patch)
treea7115d5acde41bd67fc2ba274a9b3277b2711499 /Vote.php
parent63056af6b39e8c58f5faebaa46532e0d86b29ad7 (diff)
fix invalid dates causing a null dereference error
Diffstat (limited to 'Vote.php')
-rw-r--r--Vote.php5
1 files changed, 3 insertions, 2 deletions
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) {