summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-05-24 07:47:15 -0700
committerBrion Vibber <brion@pobox.com>2010-05-24 07:47:15 -0700
commitf7add6f25f37780fde2269b254c237caea9ef98d (patch)
tree2dfa727a6398e5f6418f6b12d099257ec6b6f1d8
parentdc22ed84807555f6a16c041c16b3bc607c6587d8 (diff)
Handle funky notice deletion cases more gracefully: if we already have a deleted_notice entry, don't freak out when we try to save it again on the second try.
-rw-r--r--classes/Notice.php19
1 files changed, 12 insertions, 7 deletions
diff --git a/classes/Notice.php b/classes/Notice.php
index e173a2469..d85c8cd33 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -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