]> git.mxchange.org Git - friendica.git/commitdiff
Merge remote-tracking branch 'upstream/develop' into contact-id-new
authorMichael <heluecht@pirati.ca>
Fri, 2 Aug 2019 16:52:34 +0000 (16:52 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 2 Aug 2019 16:52:34 +0000 (16:52 +0000)
1  2 
src/Model/Item.php

index ef461fe65285a1a25af112fd330f7107dd03a388,8cca6f693ff12c5c59ef35a98a4c8854540e62fa..01c2c3459d848cb8288c6eaa5851653ef1de04cc
@@@ -1234,20 -1234,35 +1234,19 @@@ class Item extends BaseObjec
  
        private static function contactId($item)
        {
 -              $contact_id = (int)$item["contact-id"];
 -
 -              if (!empty($contact_id)) {
 -                      return $contact_id;
 -              }
 -              Logger::log('Missing contact-id. Called by: '.System::callstack(), Logger::DEBUG);
 -              /*
 -               * First we are looking for a suitable contact that matches with the author of the post
 -               * This is done only for comments
 -               */
 -              if ($item['parent-uri'] != $item['uri']) {
 +              if (!empty($item['contact-id']) && DBA::exists('contact', ['self' => true, 'id' => $item['contact-id']])) {
 +                      return $item['contact-id'];
 +              } elseif (!empty($item['uid']) && !Contact::isSharing($item['author-id'], $item['uid'])) {
 +                      return $item['author-id'];
 +              } elseif (!empty($item['contact-id'])) {
 +                      return $item['contact-id'];
 +              } else {
                        $contact_id = Contact::getIdForURL($item['author-link'], $item['uid']);
 -              }
 -
 -              // If not present then maybe the owner was found
 -              if ($contact_id == 0) {
 -                      $contact_id = Contact::getIdForURL($item['owner-link'], $item['uid']);
 -              }
 -
 -              // Still missing? Then use the "self" contact of the current user
 -              if ($contact_id == 0) {
 -                      $self = DBA::selectFirst('contact', ['id'], ['self' => true, 'uid' => $item['uid']]);
 -                      if (DBA::isResult($self)) {
 -                              $contact_id = $self["id"];
 +                      if (!empty($contact_id)) {
 +                              return $contact_id;
                        }
                }
 -              Logger::log("Contact-id was missing for post ".$item['guid']." from user id ".$item['uid']." - now set to ".$contact_id, Logger::DEBUG);
--
 -              return $contact_id;
 +              return $item['author-id'];
        }
  
        // This function will finally cover most of the preparation functionality in mod/item.php