diff --git a/lib/Poll.php b/lib/Poll.php index a720d547..73b56f85 100644 --- a/lib/Poll.php +++ b/lib/Poll.php @@ -87,6 +87,10 @@ class Poll extends PropertiesBase{ // *********** public static function Get(?int $pollId): Poll{ + if($pollId === null){ + throw new Exceptions\InvalidPollException(); + } + $result = Db::Query('SELECT * from Polls where PollId = ?', [$pollId], 'Poll'); if(sizeof($result) == 0){ @@ -97,6 +101,10 @@ class Poll extends PropertiesBase{ } public static function GetByUrlName(?string $urlName): Poll{ + if($urlName === null){ + throw new Exceptions\InvalidPollException(); + } + $result = Db::Query('SELECT * from Polls where UrlName = ?', [$urlName], 'Poll'); if(sizeof($result) == 0){ diff --git a/lib/PollItem.php b/lib/PollItem.php index 66d0c7ef..baab7d8a 100644 --- a/lib/PollItem.php +++ b/lib/PollItem.php @@ -31,6 +31,10 @@ class PollItem extends PropertiesBase{ // *********** public static function Get(?int $pollItemId): PollItem{ + if($pollItemId === null ){ + throw new Exceptions\InvalidPollItemException(); + } + $result = Db::Query('SELECT * from PollItems where PollItemId = ?', [$pollItemId], 'PollItem'); if(sizeof($result) == 0){ diff --git a/lib/User.php b/lib/User.php index b3524953..38c898bd 100644 --- a/lib/User.php +++ b/lib/User.php @@ -51,6 +51,10 @@ class User extends PropertiesBase{ } public static function GetByEmail(?string $email): User{ + if($email === null){ + throw new Exceptions\InvalidUserException(); + } + $result = Db::Query('SELECT * from Users where Email = ?', [$email], 'User'); if(sizeof($result) == 0){ diff --git a/lib/Vote.php b/lib/Vote.php index e3056f1c..96e24011 100644 --- a/lib/Vote.php +++ b/lib/Vote.php @@ -100,10 +100,9 @@ class Vote extends PropertiesBase{ $this->VoteId = Db::GetLastInsertedId(); } - public static function Get(?string $pollUrlName, ?int $userId): ?Vote{ + public static function Get(?string $pollUrlName, ?int $userId): Vote{ if($pollUrlName === null || $userId === null){ - vdd('nn'); - return null; + throw new Exceptions\InvalidVoteException(); } $result = Db::Query('SELECT v.* from Votes v inner join diff --git a/www/newsletter/subscriptions/get.php b/www/newsletter/subscriptions/get.php index 75ad0e80..656995e4 100644 --- a/www/newsletter/subscriptions/get.php +++ b/www/newsletter/subscriptions/get.php @@ -1,6 +1,8 @@