Exception handling regarding Foreign_link

This commit is contained in:
Mikael Nordfeldth
2015-07-18 11:39:34 +02:00
parent b609a3610f
commit e0084a6fdf
12 changed files with 88 additions and 102 deletions

View File

@@ -542,17 +542,17 @@ class TwitterImport
}
foreach ($status->entities->user_mentions as $mention) {
$flink = Foreign_link::getByForeignID($mention->id, TWITTER_SERVICE);
if (!empty($flink)) {
$user = User::getKV('id', $flink->user_id);
if (!empty($user)) {
$reply = new Reply();
$reply->notice_id = $notice->id;
$reply->profile_id = $user->id;
$reply->modified = $notice->created;
common_log(LOG_INFO, __METHOD__ . ": saving reply: notice {$notice->id} to profile {$user->id}");
$id = $reply->insert();
}
try {
$flink = Foreign_link::getByForeignID($mention->id, TWITTER_SERVICE);
$user = $flink->getUser();
$reply = new Reply();
$reply->notice_id = $notice->id;
$reply->profile_id = $user->id;
$reply->modified = $notice->created;
common_log(LOG_INFO, __METHOD__ . ": saving reply: notice {$notice->id} to profile {$user->id}");
$id = $reply->insert();
} catch (NoResultException $e) {
common_log(LOG_WARNING, 'No local user found for Foreign_link with local User id: '.$flink->user_id);
}
}
}