]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Delete file links when Notice is deleted
authorEvan Prodromou <evan@status.net>
Tue, 28 Dec 2010 21:44:18 +0000 (13:44 -0800)
committerEvan Prodromou <evan@status.net>
Tue, 28 Dec 2010 21:44:18 +0000 (13:44 -0800)
classes/Notice.php

index 0e8bd3c691f9126174300ed8af6b1d26385ad601..561999966c5842bb3ad2df84beae942d2e8d1416 100644 (file)
@@ -135,6 +135,7 @@ class Notice extends Memcached_DataObject
             $this->clearFaves();
             $this->clearTags();
             $this->clearGroupInboxes();
+            $this->clearFiles();
 
             // NOTE: we don't clear inboxes
             // NOTE: we don't clear queue items
@@ -1785,6 +1786,21 @@ class Notice extends Memcached_DataObject
         $reply->free();
     }
 
+    function clearFiles()
+    {
+        $f2p = new File_to_post();
+
+        $f2p->post_id = $this->id;
+
+        if ($f2p->find()) {
+            while ($f2p->fetch()) {
+                $f2p->delete();
+            }
+        }
+        // FIXME: decide whether to delete File objects
+        // ...and related (actual) files
+    }
+
     function clearRepeats()
     {
         $repeatNotice = new Notice();