]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Item.php
Merge pull request #9643 from annando/profiler
[friendica.git] / src / Model / Item.php
index 35faa407562e8a0044dea2107fa2c32934fc1d58..15ea69eeb94df1a40d0c770698a3aef767a3f4d5 100644 (file)
@@ -1186,7 +1186,9 @@ class Item
                        self::markForDeletion(['uri' => $item['uri'], 'deleted' => false], $priority);
 
                        // send the notification upstream/downstream
-                       Worker::add(['priority' => $priority, 'dont_fork' => true], "Notifier", Delivery::DELETION, intval($item['id']));
+                       if ($priority) {
+                               Worker::add(['priority' => $priority, 'dont_fork' => true], "Notifier", Delivery::DELETION, intval($item['id']));
+                       }
                } elseif ($item['uid'] != 0) {
                        Post\User::update($item['uri-id'], $item['uid'], ['hidden' => true]);
 
@@ -1431,7 +1433,7 @@ class Item
         * @param array $item
         * @return boolean item is too old
         */
-       public static function tooOld(array $item)
+       public static function isTooOld(array $item)
        {
                // check for create date and expire time
                $expire_interval = DI::config()->get('system', 'dbclean-expire-days', 0);
@@ -1566,7 +1568,7 @@ class Item
                        $item['network'] = Protocol::DFRN;
                        $item['protocol'] = Conversation::PARCEL_DIRECT;
 
-                       if (is_int($notify)) {
+                       if (in_array($notify, PRIORITIES)) {
                                $priority = $notify;
                        }
                } else {
@@ -2910,7 +2912,7 @@ class Item
                $_SESSION["authenticated"] = true;
                $_SESSION["uid"] = $contact['uid'];
 
-               return $result;
+               return (bool)$result;
        }
 
        /**
@@ -3111,6 +3113,8 @@ class Item
 
                $expired = 0;
 
+               $priority = DI::config()->get('system', 'expire-notify-priority');
+
                while ($item = Item::fetch($items)) {
                        // don't expire filed items
 
@@ -3130,7 +3134,7 @@ class Item
                                continue;
                        }
 
-                       self::markForDeletionById($item['id'], PRIORITY_LOW);
+                       self::markForDeletionById($item['id'], $priority);
 
                        ++$expired;
                }
@@ -3525,20 +3529,21 @@ class Item
         */
        public static function putInCache(&$item, $update = false)
        {
-               $body = $item["body"];
+               // Save original body to prevent addons to modify it
+               $body = $item['body'];
 
                $rendered_hash = $item['rendered-hash'] ?? '';
                $rendered_html = $item['rendered-html'] ?? '';
 
                if ($rendered_hash == ''
-                       || $rendered_html == ""
-                       || $rendered_hash != hash("md5", $item["body"])
-                       || DI::config()->get("system", "ignore_cache")
+                       || $rendered_html == ''
+                       || $rendered_hash != hash('md5', BBCode::VERSION . '::' . $body)
+                       || DI::config()->get('system', 'ignore_cache')
                ) {
                        self::addRedirToImageTags($item);
 
-                       $item["rendered-html"] = BBCode::convert($item["body"]);
-                       $item["rendered-hash"] = hash("md5", $item["body"]);
+                       $item['rendered-html'] = BBCode::convert($item['body']);
+                       $item['rendered-hash'] = hash('md5', BBCode::VERSION . '::' . $body);
 
                        $hook_data = ['item' => $item, 'rendered-html' => $item['rendered-html'], 'rendered-hash' => $item['rendered-hash']];
                        Hook::callAll('put_item_in_cache', $hook_data);
@@ -3547,27 +3552,27 @@ class Item
                        unset($hook_data);
 
                        // Force an update if the generated values differ from the existing ones
-                       if ($rendered_hash != $item["rendered-hash"]) {
+                       if ($rendered_hash != $item['rendered-hash']) {
                                $update = true;
                        }
 
                        // Only compare the HTML when we forcefully ignore the cache
-                       if (DI::config()->get("system", "ignore_cache") && ($rendered_html != $item["rendered-html"])) {
+                       if (DI::config()->get('system', 'ignore_cache') && ($rendered_html != $item['rendered-html'])) {
                                $update = true;
                        }
 
-                       if ($update && !empty($item["id"])) {
+                       if ($update && !empty($item['id'])) {
                                self::update(
                                        [
-                                               'rendered-html' => $item["rendered-html"],
-                                               'rendered-hash' => $item["rendered-hash"]
+                                               'rendered-html' => $item['rendered-html'],
+                                               'rendered-hash' => $item['rendered-hash']
                                        ],
-                                       ['id' => $item["id"]]
+                                       ['id' => $item['id']]
                                );
                        }
                }
 
-               $item["body"] = $body;
+               $item['body'] = $body;
        }
 
        /**