Fixing PHP Fatal Error for Model\Contact (usage of non available contact)

This commit is contained in:
Philipp Holzer 2019-08-28 01:22:09 +02:00
parent b2162f34e9
commit 4733b1e5e0
No known key found for this signature in database
GPG key ID: D8365C3D36B77D90

View file

@ -1795,13 +1795,19 @@ class Contact extends BaseObject
/** /**
* @brief Helper function for "updateFromProbe". Updates personal and public contact * @brief Helper function for "updateFromProbe". Updates personal and public contact
* *
* @param array $contact The personal contact entry * @param integer $id contact id
* @param array $fields The fields that are updated * @param integer $uid user id
* @param string $url The profile URL of the contact
* @param array $fields The fields that are updated
*
* @throws \Exception * @throws \Exception
*/ */
private static function updateContact($id, $uid, $url, array $fields) private static function updateContact($id, $uid, $url, array $fields)
{ {
DBA::update('contact', $fields, ['id' => $id]); if (!DBA::update('contact', $fields, ['id' => $id])) {
Logger::info('Couldn\'t update contact.', ['id' => $id, 'fields' => $fields]);
return;
}
// Search for duplicated contacts and get rid of them // Search for duplicated contacts and get rid of them
if (self::handleDuplicates(Strings::normaliseLink($url), $uid, $id) || ($uid != 0)) { if (self::handleDuplicates(Strings::normaliseLink($url), $uid, $id) || ($uid != 0)) {
@ -1814,6 +1820,11 @@ class Contact extends BaseObject
// Archive or unarchive the contact. We only need to do this for the public contact. // Archive or unarchive the contact. We only need to do this for the public contact.
// The archive/unarchive function will update the personal contacts by themselves. // The archive/unarchive function will update the personal contacts by themselves.
$contact = DBA::selectFirst('contact', [], ['id' => $id]); $contact = DBA::selectFirst('contact', [], ['id' => $id]);
if (!DBA::isResult($contact)) {
Logger::info('Couldn\'t select contact for archival.', ['id' => $id]);
return;
}
if (!empty($fields['success_update'])) { if (!empty($fields['success_update'])) {
self::unmarkForArchival($contact); self::unmarkForArchival($contact);
} elseif (!empty($fields['failure_update'])) { } elseif (!empty($fields['failure_update'])) {