Merge pull request #9552 from annando/zero-user

Avoid problems with uid=0
This commit is contained in:
Hypolite Petovan 2020-11-19 16:23:28 -05:00 committed by GitHub
commit 10a4802d81
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 4 deletions

View file

@ -342,7 +342,7 @@ function ping_init(App $a)
array_walk($notifications, function (&$notification) {
if (empty($notification['photo'])) {
$contact = Contact::getByURL($notification['url'], false, ['micro', 'id', 'avatar']);
$notification['photo'] = Contact::getMicro($contact, $notif['photo']);
$notification['photo'] = Contact::getMicro($contact, $notification['photo']);
}
$notification['timestamp'] = DateTimeFormat::local($notification['date']);

View file

@ -166,7 +166,7 @@ class Profile
}
}
$profile = User::getOwnerDataById($user['uid'], false);
$profile = !empty($user['uid']) ? User::getOwnerDataById($user['uid'], false) : [];
if (empty($profile) && empty($profiledata)) {
Logger::log('profile error: ' . DI::args()->getQueryString(), Logger::DEBUG);

View file

@ -264,7 +264,7 @@ class User
*/
public static function getById($uid, array $fields = [])
{
return DBA::selectFirst('user', $fields, ['uid' => $uid]);
return !empty($uid) ? DBA::selectFirst('user', $fields, ['uid' => $uid]) : [];
}
/**

View file

@ -55,7 +55,7 @@ class FKOAuth1 extends OAuthServer
$a = DI::app();
$record = DBA::selectFirst('user', [], ['uid' => $uid, 'blocked' => 0, 'account_expired' => 0, 'account_removed' => 0, 'verified' => 1]);
if (!DBA::isResult($record)) {
if (!DBA::isResult($record) || empty($uid)) {
Logger::info('FKOAuth1::loginUser failure', ['server' => $_SERVER]);
header('HTTP/1.0 401 Unauthorized');
die('This api requires login');