diff options
author | Zach Copley <zach@status.net> | 2010-03-05 03:14:40 +0000 |
---|---|---|
committer | Zach Copley <zach@status.net> | 2010-03-05 03:14:40 +0000 |
commit | 6a377a4ba409083e05d16b163013f0f09c606170 (patch) | |
tree | adc97101ea783c3c33f4cf916aed6fca4117c56f /classes | |
parent | 029b8c90142e08b0ed44f0528ddea7d4dcc32980 (diff) |
A better way to safely delete Foreign_links
Diffstat (limited to 'classes')
-rw-r--r-- | classes/Foreign_link.php | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/classes/Foreign_link.php b/classes/Foreign_link.php index ae8c22fd8..e47b2e309 100644 --- a/classes/Foreign_link.php +++ b/classes/Foreign_link.php @@ -113,4 +113,21 @@ class Foreign_link extends Memcached_DataObject return User::staticGet($this->user_id); } + // Make sure we only ever delete one record at a time + function safeDelete() + { + if (!empty($this->user_id) + && !empty($this->foreign_id) + && !empty($this->service)) + { + return $this->delete(); + } else { + common_debug(LOG_WARNING, + 'Foreign_link::safeDelete() tried to delete a ' + . 'Foreign_link without a fully specified compound key: ' + . var_export($this, true)); + return false; + } + } + } |