diff --git a/controller/action/DownloadActions.class.php b/controller/action/DownloadActions.class.php index 619e5fff..8e450c14 100644 --- a/controller/action/DownloadActions.class.php +++ b/controller/action/DownloadActions.class.php @@ -180,11 +180,18 @@ class DownloadActions extends Actions $prefineryUser = Prefinery::findUser($userId); - preg_match('/\?r\=(\w+)/', $prefineryUser['share_link'], $matches); + if ($prefineryUser) + { + preg_match('/\?r\=(\w+)/', $prefineryUser['share_link'], $matches); + } + else + { + $matches = null; + } return $vars + [ 'prefineryUser' => $prefineryUser, - 'referralCode' => $matches[1] ?: 'unknown' + 'referralCode' => $matches[1] ?? 'unknown' ]; } diff --git a/lib/thirdparty/Prefinery.class.php b/lib/thirdparty/Prefinery.class.php index 5df610e7..91c1215d 100644 --- a/lib/thirdparty/Prefinery.class.php +++ b/lib/thirdparty/Prefinery.class.php @@ -33,7 +33,18 @@ class Prefinery } } - $user = is_numeric($emailOrId) ? Prefinery::findTesterById($emailOrId) : Prefinery::findTesterByEmail($emailOrId); + try + { + $user = is_numeric($emailOrId) ? Prefinery::findTesterById($emailOrId) : Prefinery::findTesterByEmail($emailOrId); + } + catch (PrefineryException $e) + { + if (stripos($e->getMessage(), 'Tester is hidden.') === false) + { + throw $e; + } + } + if ($user) { unset($user['invitation_code']); // so we dont leak it