Fix deletion of temporary files in UserAvatarAction::fetchRemoteAvatar()
authorTim Düsterhus <duesterhus@woltlab.com>
Mon, 20 Apr 2015 12:28:56 +0000 (14:28 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Mon, 20 Apr 2015 12:28:56 +0000 (14:28 +0200)
wcfsetup/install/files/lib/data/user/avatar/UserAvatarAction.class.php

index 4e04324f98039560c91082a21df96dfb935b4667..a36e8c9ae7d49d251f404e4252c16c1dacce7d0d 100644 (file)
@@ -188,7 +188,9 @@ class UserAvatarAction extends AbstractDatabaseObjectAction {
                
                // rescale avatar if required
                try {
-                       $filename = $this->enforceDimensions($filename);
+                       $newFilename = $this->enforceDimensions($filename);
+                       @unlink($filename);
+                       $filename = $newFilename;
                }
                catch (\Exception $e) { /* ignore errors */ }
                
@@ -226,6 +228,8 @@ class UserAvatarAction extends AbstractDatabaseObjectAction {
                        $avatarID = $avatar->avatarID;
                }
                else {
+                       @unlink($filename);
+                       
                        // moving failed; delete avatar
                        $editor = new UserAvatarEditor($avatar);
                        $editor->delete();