]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Conversation.php
Merge pull request #7846 from annando/notes-warnings
[friendica.git] / src / Model / Conversation.php
index b8e55e5b961a349e10b4dee8b1a3412eb9d13f2e..2ef58636a0c8f0c51eab0a13a8881d42603dcd40 100644 (file)
@@ -35,10 +35,11 @@ class Conversation
         *
         * @param array $arr Item array with conversation data
         * @return array Item array with removed conversation data
+        * @throws \Exception
         */
        public static function insert(array $arr)
        {
-               if (in_array(defaults($arr, 'network', Protocol::PHANTOM),
+               if (in_array(($arr['network'] ?? '') ?: Protocol::PHANTOM,
                        [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, Protocol::TWITTER]) && !empty($arr['uri'])) {
                        $conversation = ['item-uri' => $arr['uri'], 'received' => DateTimeFormat::utcNow()];
 
@@ -75,8 +76,13 @@ class Conversation
                                        unset($old_conv['source']);
                                }
                                // Update structure data all the time but the source only when its from a better protocol.
-                               if (empty($conversation['source']) || (!empty($old_conv['source']) &&
-                                       ($old_conv['protocol'] < defaults($conversation, 'protocol', PARCEL_UNKNOWN)))) {
+                               if (
+                                       empty($conversation['source'])
+                                       || (
+                                               !empty($old_conv['source'])
+                                               && ($old_conv['protocol'] < (($conversation['protocol'] ?? '') ?: self::PARCEL_UNKNOWN))
+                                       )
+                               ) {
                                        unset($conversation['protocol']);
                                        unset($conversation['source']);
                                }