Merge pull request #10478 from annando/notice

Fix notice "undefined index: uri"
This commit is contained in:
Hypolite Petovan 2021-07-09 19:31:30 -04:00 committed by GitHub
commit f3f890702c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 136 additions and 100 deletions

View File

@ -124,7 +124,7 @@ class APContact
$apcontact = DBA::selectFirst('apcontact', [], ['addr' => $url]);
}
if (DBA::isResult($apcontact) && ($apcontact['updated'] > $ref_update) && !empty($apcontact['pubkey'])) {
if (DBA::isResult($apcontact) && ($apcontact['updated'] > $ref_update) && !empty($apcontact['pubkey']) && !empty($apcontact['uri-id'])) {
return $apcontact;
}
@ -352,7 +352,7 @@ class APContact
if (empty($apcontact['uuid'])) {
$apcontact['uri-id'] = ItemURI::getIdByURI($apcontact['url']);
} else {
$apcontact['uri-id'] = ItemURI::insert(['uri' => $apcontact['uri'], 'guid' => $apcontact['uuid']]);
$apcontact['uri-id'] = ItemURI::insert(['uri' => $apcontact['url'], 'guid' => $apcontact['uuid']]);
}
$apcontact['updated'] = DateTimeFormat::utcNow();

View File

@ -1072,12 +1072,12 @@ class Contact
return 0;
}
$contact = self::getByURL($url, false, ['id', 'network'], $uid);
$contact = self::getByURL($url, false, ['id', 'network', 'uri-id'], $uid);
if (!empty($contact)) {
$contact_id = $contact["id"];
if (empty($update)) {
if (empty($update) && (!empty($contact['uri-id']) || is_bool($update))) {
Logger::debug('Contact found', ['url' => $url, 'uid' => $uid, 'update' => $update, 'cid' => $contact_id]);
return $contact_id;
}
@ -2157,7 +2157,7 @@ class Contact
if (empty($guid)) {
$ret['uri-id'] = ItemURI::getIdByURI($ret['url']);
} else {
$ret['uri-id'] = ItemURI::insert(['uri' => $ret['uri'], 'guid' => $guid]);
$ret['uri-id'] = ItemURI::insert(['uri' => $ret['url'], 'guid' => $guid]);
}
$ret['nurl'] = Strings::normaliseLink($ret['url']);

View File

@ -333,7 +333,8 @@ class Receiver
$object_type = self::fetchObjectType($activity, $object_id, $uid);
// Fetch the content only on activities where this matters
if (in_array($type, ['as:Create', 'as:Update', 'as:Announce'])) {
// We can receive "#emojiReaction" when fetching content from Hubzilla systems
if (in_array($type, ['as:Create', 'as:Update', 'as:Announce']) || strpos($type, '#emojiReaction')) {
// Always fetch on "Announce"
$object_data = self::fetchObject($object_id, $activity['as:object'], $trust_source && ($type != 'as:Announce'), $uid);
if (empty($object_data)) {

View File

@ -71,95 +71,6 @@ return [
'theme' => 'frio',
],
],
'contact' => [
[
'id' => 42,
'uid' => 42,
'name' => 'Self contact',
'nick' => 'selfcontact',
'self' => 1,
'nurl' => 'http://localhost/profile/selfcontact',
'url' => 'http://localhost/profile/selfcontact',
'about' => 'User used in tests',
'pending' => 0,
'blocked' => 0,
'rel' => Contact::FOLLOWER,
'network' => Protocol::DFRN,
'location' => 'DFRN',
],
// Having the same name and nick allows us to test
// the fallback to api_get_nick() in api_get_user()
[
'id' => 43,
'uid' => 0,
'name' => 'othercontact',
'nick' => 'othercontact',
'self' => 0,
'nurl' => 'http://localhost/profile/othercontact',
'url' => 'http://localhost/profile/othercontact',
'pending' => 0,
'blocked' => 0,
'rel' => Contact::NOTHING,
'network' => Protocol::DFRN,
'location' => 'DFRN',
],
[
'id' => 44,
'uid' => 42,
'name' => 'Friend contact',
'nick' => 'friendcontact',
'self' => 0,
'nurl' => 'http://localhost/profile/friendcontact',
'url' => 'http://localhost/profile/friendcontact',
'pending' => 0,
'blocked' => 0,
'rel' => Contact::SHARING,
'network' => Protocol::DFRN,
'location' => 'DFRN',
],
[
'id' => 45,
'uid' => 0,
'name' => 'Friend contact',
'nick' => 'friendcontact',
'self' => 0,
'nurl' => 'http://localhost/profile/friendcontact',
'url' => 'http://localhost/profile/friendcontact',
'pending' => 0,
'blocked' => 0,
'rel' => Contact::SHARING,
'network' => Protocol::DFRN,
'location' => 'DFRN',
],
[
'id' => 46,
'uid' => 42,
'name' => 'Mutual contact',
'nick' => 'mutualcontact',
'self' => 0,
'nurl' => 'http://localhost/profile/mutualcontact',
'url' => 'http://localhost/profile/mutualcontact',
'pending' => 0,
'blocked' => 0,
'rel' => Contact::FRIEND,
'network' => Protocol::DFRN,
'location' => 'DFRN',
],
[
'id' => 47,
'uid' => 0,
'name' => 'Mutual contact',
'nick' => 'mutualcontact',
'self' => 0,
'nurl' => 'http://localhost/profile/mutualcontact',
'url' => 'http://localhost/profile/mutualcontact',
'pending' => 0,
'blocked' => 0,
'rel' => Contact::SHARING,
'network' => Protocol::DFRN,
'location' => 'DFRN',
],
],
'item-uri' => [
[
'id' => 1,
@ -191,6 +102,122 @@ return [
'uri' => '6',
'guid' => '6',
],
[
'id' => 42,
'uri' => 'http://localhost/profile/selfcontact',
'guid' => '42',
],
[
'id' => 43,
'uri' => 'http://localhost/profile/othercontact',
'guid' => '43',
],
[
'id' => 44,
'uri' => 'http://localhost/profile/friendcontact',
'guid' => '44',
],
[
'id' => 46,
'uri' => 'http://localhost/profile/mutualcontact',
'guid' => '46',
],
],
'contact' => [
[
'id' => 42,
'uid' => 42,
'uri-id' => 42,
'name' => 'Self contact',
'nick' => 'selfcontact',
'self' => 1,
'nurl' => 'http://localhost/profile/selfcontact',
'url' => 'http://localhost/profile/selfcontact',
'about' => 'User used in tests',
'pending' => 0,
'blocked' => 0,
'rel' => Contact::FOLLOWER,
'network' => Protocol::DFRN,
'location' => 'DFRN',
],
// Having the same name and nick allows us to test
// the fallback to api_get_nick() in api_get_user()
[
'id' => 43,
'uid' => 0,
'uri-id' => 43,
'name' => 'othercontact',
'nick' => 'othercontact',
'self' => 0,
'nurl' => 'http://localhost/profile/othercontact',
'url' => 'http://localhost/profile/othercontact',
'pending' => 0,
'blocked' => 0,
'rel' => Contact::NOTHING,
'network' => Protocol::DFRN,
'location' => 'DFRN',
],
[
'id' => 44,
'uid' => 42,
'uri-id' => 44,
'name' => 'Friend contact',
'nick' => 'friendcontact',
'self' => 0,
'nurl' => 'http://localhost/profile/friendcontact',
'url' => 'http://localhost/profile/friendcontact',
'pending' => 0,
'blocked' => 0,
'rel' => Contact::SHARING,
'network' => Protocol::DFRN,
'location' => 'DFRN',
],
[
'id' => 45,
'uid' => 0,
'uri-id' => 44,
'name' => 'Friend contact',
'nick' => 'friendcontact',
'self' => 0,
'nurl' => 'http://localhost/profile/friendcontact',
'url' => 'http://localhost/profile/friendcontact',
'pending' => 0,
'blocked' => 0,
'rel' => Contact::SHARING,
'network' => Protocol::DFRN,
'location' => 'DFRN',
],
[
'id' => 46,
'uid' => 42,
'uri-id' => 46,
'name' => 'Mutual contact',
'nick' => 'mutualcontact',
'self' => 0,
'nurl' => 'http://localhost/profile/mutualcontact',
'url' => 'http://localhost/profile/mutualcontact',
'pending' => 0,
'blocked' => 0,
'rel' => Contact::FRIEND,
'network' => Protocol::DFRN,
'location' => 'DFRN',
],
[
'id' => 47,
'uid' => 0,
'uri-id' => 46,
'name' => 'Mutual contact',
'nick' => 'mutualcontact',
'self' => 0,
'nurl' => 'http://localhost/profile/mutualcontact',
'url' => 'http://localhost/profile/mutualcontact',
'pending' => 0,
'blocked' => 0,
'rel' => Contact::SHARING,
'network' => Protocol::DFRN,
'location' => 'DFRN',
],
],
'verb' => [
[

View File

@ -33,10 +33,18 @@ return [
'theme' => 'frio',
],
],
'item-uri' => [
[
'id' => 42,
'uri' => 'http://localhost/profile/selfcontact',
'guid' => '42',
],
],
'contact' => [
[
'id' => 42,
'uid' => 42,
'uri-id' => 42,
'name' => 'Self contact',
'nick' => 'selfcontact',
'self' => 1,