]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Item.php
Merge pull request #9 from nupplaphil/dependabot/composer/guzzlehttp/guzzle-6.5.8
[friendica.git] / src / Model / Item.php
index d99f23fb968fd0ce057792b57daa7c488bbc58ae..c87dacd9b238bedbe0db0c3bb1d0c1c93e3fb014 100644 (file)
@@ -343,7 +343,7 @@ class Item
 
                Post\Category::storeTextByURIId($item['uri-id'], $item['uid'], '');
 
-               if (!Post::exists(['`uri-id` = ? AND `uid` != 0 AND NOT `deleted`', $item['uri-id']])) {
+               if (!Post::exists(["`uri-id` = ? AND `uid` != 0 AND NOT `deleted`", $item['uri-id']])) {
                        self::markForDeletion(['uri-id' => $item['uri-id'], 'uid' => 0, 'deleted' => false], $priority);
                }
 
@@ -465,7 +465,7 @@ class Item
         * @param array $item The item fields that are to be inserted
         * @throws \Exception
         */
-       private static function spool($orig_item)
+       private static function spool(array $item)
        {
                // Now we store the data in the spool directory
                // We use "microtime" to keep the arrival order and "mt_rand" to avoid duplicates
@@ -475,7 +475,7 @@ class Item
                if ($spoolpath != '') {
                        $spool = $spoolpath . '/' . $file;
 
-                       file_put_contents($spool, json_encode($orig_item));
+                       file_put_contents($spool, json_encode($item));
                        Logger::warning("Item wasn't stored - Item was spooled into file", ['file' => $file]);
                }
        }
@@ -511,7 +511,7 @@ class Item
                        }
                } elseif ($item['network'] == Protocol::OSTATUS) {
                        // Check for an existing post with the same content. There seems to be a problem with OStatus.
-                       $condition = ['`body` = ? AND `network` = ? AND `created` = ? AND `contact-id` = ? AND `uid` = ?',
+                       $condition = ["`body` = ? AND `network` = ? AND `created` = ? AND `contact-id` = ? AND `uid` = ?",
                                        $item['body'], $item['network'], $item['created'], $item['contact-id'], $item['uid']];
                        if (Post::exists($condition)) {
                                Logger::notice('duplicated item with the same body found.', $item);
@@ -1841,13 +1841,13 @@ class Item
                $parsed = parse_url($uri);
 
                // Remove the scheme to make sure that "https" and "http" doesn't make a difference
-               unset($parsed["scheme"]);
+               unset($parsed['scheme']);
 
                // Glue it together to be able to make a hash from it
-               $host_id = implode("/", $parsed);
+               $host_id = implode('/', $parsed);
 
                // Use a mixture of several hashes to provide some GUID like experience
-               return hash("crc32", $host) . '-'. hash('joaat', $host_id) . '-'. hash('fnv164', $host_id);
+               return hash('crc32', $host) . '-'. hash('joaat', $host_id) . '-'. hash('fnv164', $host_id);
        }
 
        /**
@@ -1859,9 +1859,9 @@ class Item
         * @return string
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
-       public static function newURI($uid, $guid = "")
+       public static function newURI(int $uid, string $guid = ''): string
        {
-               if ($guid == "") {
+               if ($guid == '') {
                        $guid = System::createUUID();
                }
 
@@ -2831,7 +2831,8 @@ class Item
                        $shared_uri_id = 0;
                        $shared_links = [];
                }
-               $attachments = Post\Media::splitAttachments($item['uri-id'], $item['guid'] ?? '', $shared_links, $item['has-media']);
+
+               $attachments = Post\Media::splitAttachments($item['uri-id'], $item['guid'] ?? '', $shared_links, $item['has-media'] ?? false);
                $item['body'] = self::replaceVisualAttachments($attachments, $item['body'] ?? '');
 
                $item['body'] = preg_replace("/\s*\[attachment .*?\].*?\[\/attachment\]\s*/ism", "\n", $item['body']);