From e9798a01fea9a4da0efce4e33c7c9a13deb47511 Mon Sep 17 00:00:00 2001 From: grandeljay Date: Wed, 30 Aug 2023 13:11:12 +0200 Subject: [PATCH] fix: user construct on login --- src/classes/wishthis/Page.php | 5 ++++- src/classes/wishthis/User.php | 18 +++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/classes/wishthis/Page.php b/src/classes/wishthis/Page.php index aa82d084..0a4cb6b3 100644 --- a/src/classes/wishthis/Page.php +++ b/src/classes/wishthis/Page.php @@ -114,8 +114,11 @@ class Page } /** - * Non-Static + * The page name. Is used for the HTML `title` and `h1` tags. + * + * @var string */ + private string $name; public string $language = DEFAULT_LOCALE; public array $messages = array(); public string $link_preview; diff --git a/src/classes/wishthis/User.php b/src/classes/wishthis/User.php index 6c6b0c5a..21a617e4 100644 --- a/src/classes/wishthis/User.php +++ b/src/classes/wishthis/User.php @@ -96,9 +96,9 @@ class User /** * A unix timestamp of the users birthdate. * - * @var int + * @var int|null */ - private int $birthdate; + private ?int $birthdate; /** * More accurately, this is the users locale (e. g. `en_GB`). @@ -161,17 +161,17 @@ class User $this->id = $fields['id']; $this->email = $fields['email']; $this->password = $fields['password']; - $this->password_reset_token = $fields['password_reset_token']; - $this->password_reset_valid_until = $fields['password_reset_valid_until']; - $this->last_login = $fields['last_login']; + $this->password_reset_token = $fields['password_reset_token'] ?? ''; + $this->password_reset_valid_until = \strtotime($fields['password_reset_valid_until']); + $this->last_login = \strtotime($fields['last_login']); $this->power = $fields['power']; $this->birthdate = $fields['birthdate']; $this->language = $fields['language']; $this->currency = $fields['currency']; - $this->name_first = $fields['name_first']; - $this->name_last = $fields['name_last']; - $this->name_nick = $fields['name_nick']; - $this->channel = $fields['channel']; + $this->name_first = $fields['name_first'] ?? ''; + $this->name_last = $fields['name_last'] ?? ''; + $this->name_nick = $fields['name_nick'] ?? ''; + $this->channel = $fields['channel'] ?? ''; $this->advertisements = $fields['advertisements']; }