summaryrefslogtreecommitdiff
path: root/plugins/TwitterBridge
diff options
context:
space:
mode:
authorZach Copley <zach@status.net>2010-03-05 02:27:01 +0000
committerZach Copley <zach@status.net>2010-03-05 02:27:01 +0000
commit029b8c90142e08b0ed44f0528ddea7d4dcc32980 (patch)
tree193346cddb9b2762163d28e2418322747a2a96d6 /plugins/TwitterBridge
parent980d1a66ec0bb5b42ddb39e253fba9bad1b41aca (diff)
Fix for errant deletion of all Twitter foreign_links
Diffstat (limited to 'plugins/TwitterBridge')
-rw-r--r--plugins/TwitterBridge/twitter.php11
-rw-r--r--plugins/TwitterBridge/twitterauthorization.php13
-rw-r--r--plugins/TwitterBridge/twittersettings.php11
3 files changed, 32 insertions, 3 deletions
diff --git a/plugins/TwitterBridge/twitter.php b/plugins/TwitterBridge/twitter.php
index ceb83b037..42db3c673 100644
--- a/plugins/TwitterBridge/twitter.php
+++ b/plugins/TwitterBridge/twitter.php
@@ -264,7 +264,16 @@ function remove_twitter_link($flink)
common_log(LOG_INFO, 'Removing Twitter bridge Foreign link for ' .
"user $user->nickname (user id: $user->id).");
- $result = $flink->delete();
+ $result = false;
+
+ // Be extra careful to make sure we have a good flink
+ // before deleting
+ if (!empty($flink->user_id)
+ && !empty($flink->foreign_id)
+ && !empty($flink->service))
+ {
+ $result = $flink->delete();
+ }
if (empty($result)) {
common_log(LOG_ERR, 'Could not remove Twitter bridge ' .
diff --git a/plugins/TwitterBridge/twitterauthorization.php b/plugins/TwitterBridge/twitterauthorization.php
index c93f6666b..029c3a44b 100644
--- a/plugins/TwitterBridge/twitterauthorization.php
+++ b/plugins/TwitterBridge/twitterauthorization.php
@@ -273,7 +273,13 @@ class TwitterauthorizationAction extends Action
$flink->user_id = $user_id;
$flink->service = TWITTER_SERVICE;
- $flink->delete(); // delete stale flink, if any
+
+ // delete stale flink, if any
+ $result = $flink->find(true);
+
+ if (!empty($result)) {
+ $flink->delete();
+ }
$flink->user_id = $user_id;
$flink->foreign_id = $twuid;
@@ -455,6 +461,11 @@ class TwitterauthorizationAction extends Action
$user = User::register($args);
+ if (empty($user)) {
+ $this->serverError(_('Error registering user.'));
+ return;
+ }
+
$result = $this->saveForeignLink($user->id,
$this->twuid,
$this->access_token);
diff --git a/plugins/TwitterBridge/twittersettings.php b/plugins/TwitterBridge/twittersettings.php
index 0137060e9..f22a059f7 100644
--- a/plugins/TwitterBridge/twittersettings.php
+++ b/plugins/TwitterBridge/twittersettings.php
@@ -250,7 +250,16 @@ class TwittersettingsAction extends ConnectSettingsAction
$user = common_current_user();
$flink = Foreign_link::getByUserID($user->id, TWITTER_SERVICE);
- $result = $flink->delete();
+ $result = false;
+
+ // Be extra careful to make sure we have a good flink
+ // before deleting
+ if (!empty($flink->user_id)
+ && !empty($flink->foreign_id)
+ && !empty($flink->service))
+ {
+ $result = $flink->delete();
+ }
if (empty($result)) {
common_log_db_error($flink, 'DELETE', __FILE__);