summaryrefslogtreecommitdiff
path: root/plugins/WikiHowProfile
diff options
context:
space:
mode:
authorCraig Andrews <candrews@integralblue.com>2010-10-14 15:27:17 -0400
committerCraig Andrews <candrews@integralblue.com>2010-10-14 15:27:17 -0400
commit0721d8d3e257709d27994eb4ab4bbe60abc93e2e (patch)
tree58cb9e3b5f8df089353617b498c340ad9276519b /plugins/WikiHowProfile
parentf79dbaf9a76c10969dbc45fd43a0bb26f5f64ed4 (diff)
parentfc6711327bcb2319139171ad3353603753f13eaa (diff)
Merge remote branch 'statusnet/0.9.x' into 1.0.x
Diffstat (limited to 'plugins/WikiHowProfile')
-rw-r--r--plugins/WikiHowProfile/WikiHowProfilePlugin.php31
1 files changed, 18 insertions, 13 deletions
diff --git a/plugins/WikiHowProfile/WikiHowProfilePlugin.php b/plugins/WikiHowProfile/WikiHowProfilePlugin.php
index fa683c483..753dff5a3 100644
--- a/plugins/WikiHowProfile/WikiHowProfilePlugin.php
+++ b/plugins/WikiHowProfile/WikiHowProfilePlugin.php
@@ -174,20 +174,25 @@ class WikiHowProfilePlugin extends Plugin
// @fixme this should be better encapsulated
// ripped from OStatus via oauthstore.php (for old OMB client)
$temp_filename = tempnam(sys_get_temp_dir(), 'listener_avatar');
- if (!copy($url, $temp_filename)) {
- throw new ServerException(sprintf(_m("Unable to fetch avatar from %s."), $url));
- }
-
- $profile = $user->getProfile();
- $id = $profile->id;
- // @fixme should we be using different ids?
+ try {
+ if (!copy($url, $temp_filename)) {
+ throw new ServerException(sprintf(_m("Unable to fetch avatar from %s."), $url));
+ }
- $imagefile = new ImageFile($id, $temp_filename);
- $filename = Avatar::filename($id,
- image_type_to_extension($imagefile->type),
- null,
- common_timestamp());
- rename($temp_filename, Avatar::path($filename));
+ $profile = $user->getProfile();
+ $id = $profile->id;
+ // @fixme should we be using different ids?
+
+ $imagefile = new ImageFile($id, $temp_filename);
+ $filename = Avatar::filename($id,
+ image_type_to_extension($imagefile->type),
+ null,
+ common_timestamp());
+ rename($temp_filename, Avatar::path($filename));
+ } catch (Exception $e) {
+ unlink($temp_filename);
+ throw $e;
+ }
$profile->setOriginal($filename);
}
}