We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 029b8c90 authored by Zach Copley's avatar Zach Copley

Fix for errant deletion of all Twitter foreign_links

parent 980d1a66
......@@ -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 ' .
......
......@@ -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);
......
......@@ -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__);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment