From 1a1e44cdfde155279e3890c20963b5dbb9d6a0ea Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Wed, 6 Jan 2016 16:14:26 +0100 Subject: [PATCH] Issue #118 wanted better TOR support, now Avatar URLs are not stored There was no reason to store the generated Avatar URLs because it's so cheap to generate them on the fly. --- classes/Avatar.php | 20 +++---------- classes/Profile.php | 1 - plugins/TwitterBridge/lib/twitterimport.php | 1 - scripts/updateurls.php | 31 --------------------- 4 files changed, 4 insertions(+), 49 deletions(-) diff --git a/classes/Avatar.php b/classes/Avatar.php index 1722b85b6b..5ce2712dfb 100644 --- a/classes/Avatar.php +++ b/classes/Avatar.php @@ -1,14 +1,13 @@ array('type' => 'int', 'not null' => true, 'description' => 'image height'), 'mediatype' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'file type'), 'filename' => array('type' => 'varchar', 'length' => 191, 'description' => 'local filename, if local'), - 'url' => array('type' => 'text', 'description' => 'avatar location, not indexed - do not use in WHERE statement'), 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'), 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'), ), @@ -211,12 +205,7 @@ class Avatar extends Managed_DataObject function displayUrl() { - $server = common_config('avatar', 'server'); - if ($server && !empty($this->filename)) { - return Avatar::url($this->filename); - } else { - return $this->url; - } + return Avatar::url($this->filename); } static function urlByProfile(Profile $target, $width=null, $height=null) { @@ -256,7 +245,6 @@ class Avatar extends Managed_DataObject $scaled->original = false; $scaled->width = $width; $scaled->height = $height; - $scaled->url = Avatar::url($filename); $scaled->filename = $filename; $scaled->created = common_sql_now(); diff --git a/classes/Profile.php b/classes/Profile.php index 00701bc748..554215a973 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -175,7 +175,6 @@ class Profile extends Managed_DataObject $avatar->mediatype = image_type_to_mime_type($imagefile->type); $avatar->filename = $filename; $avatar->original = true; - $avatar->url = Avatar::url($filename); $avatar->created = common_sql_now(); // XXX: start a transaction here diff --git a/plugins/TwitterBridge/lib/twitterimport.php b/plugins/TwitterBridge/lib/twitterimport.php index 74495d7ba3..fe11695c1f 100644 --- a/plugins/TwitterBridge/lib/twitterimport.php +++ b/plugins/TwitterBridge/lib/twitterimport.php @@ -366,7 +366,6 @@ class TwitterImport $avatar->original = 1; // this is an original/"uploaded" avatar $avatar->mediatype = $mediatype; $avatar->filename = $filename; - $avatar->url = Avatar::url($filename); $avatar->width = $this->avatarsize; $avatar->height = $this->avatarsize; diff --git a/scripts/updateurls.php b/scripts/updateurls.php index 35b835e494..8657d80b84 100755 --- a/scripts/updateurls.php +++ b/scripts/updateurls.php @@ -51,7 +51,6 @@ function updateUserUrls() $profile = $user->getProfile(); updateProfileUrl($profile); - updateAvatarUrls($profile); } catch (Exception $e) { echo "Error updating URLs: " . $e->getMessage(); } @@ -67,36 +66,6 @@ function updateProfileUrl($profile) $profile->update($orig); } -function updateAvatarUrls($profile) -{ - $avatar = new Avatar(); - - $avatar->profile_id = $profile->id; - if ($avatar->find()) { - while ($avatar->fetch()) { - $orig_url = $avatar->url; - $avatar->url = Avatar::url($avatar->filename); - if ($avatar->url != $orig_url) { - $sql = - "UPDATE avatar SET url = '" . $avatar->url . "' ". - "WHERE profile_id = " . $avatar->profile_id . " ". - "AND width = " . $avatar->width . " " . - "AND height = " . $avatar->height . " "; - - if ($avatar->original) { - $sql .= "AND original = 1 "; - } - - if (!$avatar->query($sql)) { - throw new Exception("Can't update avatar for user " . $profile->nickname . "."); - } else { - $touched = true; - } - } - } - } -} - function updateGroupUrls() { printfnq("Updating group URLs...\n"); -- 2.39.5