From 94f2f96f2ebe8d7b127ec643f84cbfb20f4bb475 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 19 Nov 2010 15:51:08 -0800 Subject: [PATCH] Ticket #2724: gracefully handle attempts to delete or fave/unfave a remote Twitter notice if a failure occurs. Most annoying error case being where the notice was already faved or deleted on Twitter! :) Such errors will now just fail out and log a note to the syslog -- the rest of what we were doing will continue on unhindered, so you can still delete, favorite, etc and it just won't sync the info over in that case. --- plugins/TwitterBridge/TwitterBridgePlugin.php | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/plugins/TwitterBridge/TwitterBridgePlugin.php b/plugins/TwitterBridge/TwitterBridgePlugin.php index 097d4486f9..b520a4544f 100644 --- a/plugins/TwitterBridge/TwitterBridgePlugin.php +++ b/plugins/TwitterBridge/TwitterBridgePlugin.php @@ -427,10 +427,14 @@ class TwitterBridgePlugin extends Plugin return true; } - $token = TwitterOAuthClient::unpackToken($flink->credentials); - $client = new TwitterOAuthClient($token->key, $token->secret); + try { + $token = TwitterOAuthClient::unpackToken($flink->credentials); + $client = new TwitterOAuthClient($token->key, $token->secret); - $client->statusesDestroy($n2s->status_id); + $client->statusesDestroy($n2s->status_id); + } catch (Exception $e) { + common_log(LOG_ERR, "Error attempting to delete bridged notice from Twitter: " . $e->getMessage()); + } $n2s->delete(); } @@ -464,10 +468,14 @@ class TwitterBridgePlugin extends Plugin return true; } - $token = TwitterOAuthClient::unpackToken($flink->credentials); - $client = new TwitterOAuthClient($token->key, $token->secret); + try { + $token = TwitterOAuthClient::unpackToken($flink->credentials); + $client = new TwitterOAuthClient($token->key, $token->secret); - $client->favoritesCreate($status_id); + $client->favoritesCreate($status_id); + } catch (Exception $e) { + common_log(LOG_ERR, "Error attempting to favorite bridged notice on Twitter: " . $e->getMessage()); + } return true; } @@ -500,10 +508,14 @@ class TwitterBridgePlugin extends Plugin return true; } - $token = TwitterOAuthClient::unpackToken($flink->credentials); - $client = new TwitterOAuthClient($token->key, $token->secret); + try { + $token = TwitterOAuthClient::unpackToken($flink->credentials); + $client = new TwitterOAuthClient($token->key, $token->secret); - $client->favoritesDestroy($status_id); + $client->favoritesDestroy($status_id); + } catch (Exception $e) { + common_log(LOG_ERR, "Error attempting to unfavorite bridged notice on Twitter: " . $e->getMessage()); + } return true; } -- 2.39.5