]> git.mxchange.org Git - friendica.git/blobdiff - src/Worker/Delivery.php
Merge pull request #5563 from MrPetovan/bug/5470-fix-various-notices
[friendica.git] / src / Worker / Delivery.php
index 022faa2d7ac26a07e5d0a14be27b8f49baa6a47c..32bcdfcc40c137b8cea6d42fa32d11fc5d73c256 100644 (file)
@@ -59,7 +59,7 @@ class Delivery extends BaseObject
                        }
                        $parent_id = intval($item['parent']);
 
-                       $condition = ['id' => [$item_id, $parent_id], 'visible' => true, 'moderated' => false];
+                       $condition = ['id' => [$item_id, $parent_id], 'moderated' => false];
                        $params = ['order' => ['id']];
                        $itemdata = Item::select([], $condition, $params);
 
@@ -75,6 +75,16 @@ class Delivery extends BaseObject
                        }
                        DBA::close($itemdata);
 
+                       if (empty($target_item)) {
+                               logger('Item ' . $item_id . "wasn't found. Quitting here.");
+                               return;
+                       }
+
+                       if (empty($parent)) {
+                               logger('Parent ' . $parent_id . ' for item ' . $item_id . "wasn't found. Quitting here.");
+                               return;
+                       }
+
                        $uid = $target_item['contact-uid'];
 
                        // avoid race condition with deleting entries
@@ -265,6 +275,12 @@ class Delivery extends BaseObject
 
                        $user = DBA::selectFirst('user', [], ['uid' => $target_uid]);
 
+                       // This should also never fail
+                       if (!DBA::isResult($user)) {
+                               logger('No user found for uid ' . $target_uid);
+                               return;
+                       }
+
                        $target_importer = array_merge($target_importer, $user);
 
                        // Set the user id. This is important if this is a public contact
@@ -277,7 +293,7 @@ class Delivery extends BaseObject
                // Se we transmit with the new method and via Diaspora as a fallback
                if (!empty($items) && (($items[0]['uid'] == 0) || ($contact['uid'] == 0))) {
                        // Transmit in public if it's a relay post
-                       $public_dfrn = ($contact['contact-type'] == ACCOUNT_TYPE_RELAY);
+                       $public_dfrn = ($contact['contact-type'] == Contact::ACCOUNT_TYPE_RELAY);
 
                        $deliver_status = DFRN::transmit($owner, $contact, $atom, $public_dfrn);
 
@@ -331,7 +347,7 @@ class Delivery extends BaseObject
        private static function deliverDiaspora($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup)
        {
                // We don't treat Forum posts as "wall-to-wall" to be able to post them via Diaspora
-               $walltowall = $top_level && ($owner['id'] != $items[0]['contact-id']) & ($owner['account-type'] != ACCOUNT_TYPE_COMMUNITY);
+               $walltowall = $top_level && ($owner['id'] != $items[0]['contact-id']) & ($owner['account-type'] != Contact::ACCOUNT_TYPE_COMMUNITY);
 
                if ($public_message) {
                        $loc = 'public batch ' . $contact['batch'];
@@ -424,7 +440,7 @@ class Delivery extends BaseObject
 
                // only expose our real email address to true friends
 
-               if (($contact['rel'] == CONTACT_IS_FRIEND) && !$contact['blocked']) {
+               if (($contact['rel'] == Contact::FRIEND) && !$contact['blocked']) {
                        if ($reply_to) {
                                $headers  = 'From: ' . Email::encodeHeader($local_user['username'],'UTF-8') . ' <' . $reply_to.'>' . "\n";
                                $headers .= 'Sender: ' . $local_user['email'] . "\n";