Add Exception for empty User::getOwnerDataById(0 return case in Protocol\ActivityPub\Transmitter::getProfile()

- Address https://github.com/friendica/friendica/issues/10473#issuecomment-882781552
- Add try-catch blocks to all references of Protocol\ActivityPub\Transmitter::getProfile()
This commit is contained in:
Hypolite Petovan 2021-07-20 13:04:25 -04:00
parent 71a0c52dc3
commit dfb043ce60
5 changed files with 53 additions and 26 deletions

View file

@ -52,12 +52,13 @@ class Profile extends BaseProfile
if (ActivityPub::isRequest()) {
$user = DBA::selectFirst('user', ['uid'], ['nickname' => $parameters['nickname']]);
if (DBA::isResult($user)) {
// The function returns an empty array when the account is removed, expired or blocked
$data = ActivityPub\Transmitter::getProfile($user['uid']);
if (!empty($data)) {
try {
$data = ActivityPub\Transmitter::getProfile($user['uid']);
header('Access-Control-Allow-Origin: *');
header('Cache-Control: max-age=23200, stale-while-revalidate=23200');
System::jsonExit($data, 'application/activity+json');
} catch (HTTPException\NotFoundException $e) {
System::jsonError(404, ['error' => 'Record not found']);
}
}