]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Item.php
Merge pull request #8629 from annando/item-insert
[friendica.git] / src / Model / Item.php
index d3b2054deb294998b599d1562253887a1bb9be2a..f10537d75ab2de88a2a3eb8731636981be3d07a5 100644 (file)
@@ -1331,7 +1331,13 @@ class Item
                }
        }
 
-       private static function isDuplicate($item)
+       /**
+        * Check if the item array is a duplicate
+        *
+        * @param array $item
+        * @return boolean is it a duplicate?
+        */
+       private static function isDuplicate(array $item)
        {
                // Checking if there is already an item with the same guid
                $condition = ['guid' => $item['guid'], 'network' => $item['network'], 'uid' => $item['uid']];
@@ -1373,7 +1379,7 @@ class Item
                 * There is a timing issue here that sometimes creates double postings.
                 * An unique index would help - but the limitations of MySQL (maximum size of index values) prevent this.
                 */
-               if (($item["uid"] == 0) && self::exists(['uri' => trim($item['uri']), 'uid' => 0])) {
+               if (($item['uid'] == 0) && self::exists(['uri' => trim($item['uri']), 'uid' => 0])) {
                        Logger::notice('Global item already stored.', ['uri' => $item['uri'], 'network' => $item['network']]);
                        return true;
                }
@@ -1381,7 +1387,13 @@ class Item
                return false;
        }
 
-       private static function validItem($item)
+       /**
+        * Check if the item array is valid
+        *
+        * @param array $item
+        * @return boolean item is valid
+        */
+       private static function isValid(array $item)
        {
                // When there is no content then we don't post it
                if ($item['body'].$item['title'] == '') {
@@ -1470,7 +1482,13 @@ class Item
                return true;
        }
 
-       private static function getDuplicateID($item)
+       /**
+        * Return the id of the given item array if it has been stored before
+        *
+        * @param array $item
+        * @return integer item id
+        */
+       private static function getDuplicateID(array $item)
        {
                if (empty($item['network']) || in_array($item['network'], Protocol::FEDERATED)) {
                        $condition = ["`uri` = ? AND `uid` = ? AND `network` IN (?, ?, ?, ?)",
@@ -1495,7 +1513,13 @@ class Item
                return 0;
        }
 
-       private static function getParentData($item)
+       /**
+        * Fetch parent data for the given item array
+        *
+        * @param array $item
+        * @return array item array with parent data
+        */
+       private static function getParentData(array $item)
        {
                // find the parent and snarf the item id and ACLs
                // and anything else we need to inherit
@@ -1576,7 +1600,13 @@ class Item
                return $item;
        }
 
-       private static function getGravity($item)
+       /**
+        * Get the gravity for the given item array
+        *
+        * @param array $item
+        * @return integer gravity
+        */
+       private static function getGravity(array $item)
        {
                $activity = DI::activity();
 
@@ -1712,7 +1742,7 @@ class Item
                // The contact-id should be set before "self::insert" was called - but there seems to be issues sometimes
                $item["contact-id"] = self::contactId($item);
 
-               if (!self::validItem($item)) {
+               if (!self::isValid($item)) {
                        return 0;
                }