]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Post/History.php
Check the edit date before storing history
[friendica.git] / src / Model / Post / History.php
index e889ccf20559b0344e308fb22646ee26cb3de59e..24ee7c1e7d13bea850e12b6f91d07a04cd21eb95 100644 (file)
@@ -38,14 +38,20 @@ class History
        public static function add(int $uri_id, array $item)
        {
                $allfields = DBStructure::definition('', false);
-               $fields = array_keys($allfields['post-history']['fields']);
+               $fields    = array_keys($allfields['post-history']['fields']);
 
                $post = Post::selectFirstPost($fields, ['uri-id' => $uri_id]);
                if (empty($post)) {
+                       Logger::warning('Post not found', ['uri-id' => $uri_id]);
                        return;
                }
 
-               $update = false;
+               if ($item['edited'] <= $post['edited']) {
+                       Logger::info('New edit date is not newer than the old one', ['uri-id' => $uri_id, 'old' => $post['edited'], 'new' => $item['edited']]);
+                       return;
+               }
+
+               $update  = false;
                $changed = DBStructure::getFieldsForTable('post-history', $item);
                unset($changed['uri-id']);
                unset($changed['edited']);