]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Handle funky notice deletion cases more gracefully: if we already have a deleted_noti...
authorBrion Vibber <brion@pobox.com>
Mon, 24 May 2010 14:47:15 +0000 (07:47 -0700)
committerBrion Vibber <brion@pobox.com>
Mon, 24 May 2010 14:47:15 +0000 (07:47 -0700)
classes/Notice.php

index e173a2469095d7fd4410ecaee7333fe78322b904..d85c8cd33acf802c0f566016cfc632b0cd0bd809 100644 (file)
@@ -97,15 +97,20 @@ class Notice extends Memcached_DataObject
         // For auditing purposes, save a record that the notice
         // was deleted.
 
-        $deleted = new Deleted_notice();
+        // @fixme we have some cases where things get re-run and so the
+        // insert fails.
+        $deleted = Deleted_notice::staticGet('id', $this->id);
+        if (!$deleted) {
+            $deleted = new Deleted_notice();
 
-        $deleted->id         = $this->id;
-        $deleted->profile_id = $this->profile_id;
-        $deleted->uri        = $this->uri;
-        $deleted->created    = $this->created;
-        $deleted->deleted    = common_sql_now();
+            $deleted->id         = $this->id;
+            $deleted->profile_id = $this->profile_id;
+            $deleted->uri        = $this->uri;
+            $deleted->created    = $this->created;
+            $deleted->deleted    = common_sql_now();
 
-        $deleted->insert();
+            $deleted->insert();
+        }
 
         // Clear related records