@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Use a disk-based default avatar, not a database-based one

Summary:
This is mostly in an effort to simplify D2323. Currently, we load one image into the database by default. This is a weird special case that makes things more complicated than necessary.

Instead, use a disk-based default avatar.

Test Plan: Verified that a user without an image appears with the default avatar as a handle, in profile settings, and on their person page.

Reviewers: btrahan, vrana, edward, jungejason

Reviewed By: vrana

CC: aran

Maniphest Tasks: T345

Differential Revision: https://secure.phabricator.com/D2331

+26 -45
-4
conf/default.conf.php
··· 31 31 // you through setting up Phabricator. 32 32 'phabricator.setup' => false, 33 33 34 - // The default PHID for users who haven't uploaded a profile image. It should 35 - // be 50x50px. 36 - 'user.default-profile-image-phid' => 'PHID-FILE-4d61229816cfe6f2b2a3', 37 - 38 34 // -- IMPORTANT! Security! -------------------------------------------------- // 39 35 40 36 // IMPORTANT: By default, Phabricator serves files from the same domain the
+1 -9
src/applications/conduit/method/user/base/ConduitAPI_user_Method.php
··· 22 22 abstract class ConduitAPI_user_Method extends ConduitAPIMethod { 23 23 24 24 protected function buildUserInformationDictionary(PhabricatorUser $user) { 25 - $src_phid = $user->getProfileImagePHID(); 26 - $file = id(new PhabricatorFile())->loadOneWhere('phid = %s', $src_phid); 27 - if ($file) { 28 - $picture = $file->getBestURI(); 29 - } else { 30 - $picture = null; 31 - } 32 - 33 25 return array( 34 26 'phid' => $user->getPHID(), 35 27 'userName' => $user->getUserName(), 36 28 'realName' => $user->getRealName(), 37 29 'email' => $user->getEmail(), 38 - 'image' => $picture, 30 + 'image' => $user->loadProfileImageURI(), 39 31 'uri' => PhabricatorEnv::getURI('/p/'.$user->getUsername().'/'), 40 32 ); 41 33 }
-3
src/applications/conduit/method/user/base/__init__.php
··· 7 7 8 8 9 9 phutil_require_module('phabricator', 'applications/conduit/method/base'); 10 - phutil_require_module('phabricator', 'applications/files/storage/file'); 11 10 phutil_require_module('phabricator', 'infrastructure/env'); 12 - 13 - phutil_require_module('phutil', 'utils'); 14 11 15 12 16 13 phutil_require_source('ConduitAPI_user_Method.php');
+1 -7
src/applications/people/controller/profile/PhabricatorPeopleProfileController.php
··· 116 116 throw new Exception("Unknown page '{$this->page}'!"); 117 117 } 118 118 119 - $src_phid = $user->getProfileImagePHID(); 120 - $file = id(new PhabricatorFile())->loadOneWhere('phid = %s', $src_phid); 121 - if ($file) { 122 - $picture = $file->getBestURI(); 123 - } else { 124 - $picture = null; 125 - } 119 + $picture = $user->loadProfileImageURI(); 126 120 127 121 $header = new PhabricatorProfileHeaderView(); 128 122 $header
-1
src/applications/people/controller/profile/__init__.php
··· 10 10 phutil_require_module('phabricator', 'applications/auth/oauth/provider/base'); 11 11 phutil_require_module('phabricator', 'applications/feed/builder/feed'); 12 12 phutil_require_module('phabricator', 'applications/feed/query'); 13 - phutil_require_module('phabricator', 'applications/files/storage/file'); 14 13 phutil_require_module('phabricator', 'applications/markup/engine'); 15 14 phutil_require_module('phabricator', 'applications/people/controller/base'); 16 15 phutil_require_module('phabricator', 'applications/people/storage/profile');
+1 -8
src/applications/people/controller/settings/panels/profile/PhabricatorUserProfileSettingsPanelController.php
··· 107 107 } 108 108 } 109 109 110 - $file = id(new PhabricatorFile())->loadOneWhere( 111 - 'phid = %s', 112 - $user->getProfileImagePHID()); 113 - if ($file) { 114 - $img_src = $file->getBestURI(); 115 - } else { 116 - $img_src = null; 117 - } 110 + $img_src = $user->loadProfileImageURI(); 118 111 $profile_uri = PhabricatorEnv::getURI('/p/'.$user->getUsername().'/'); 119 112 120 113 $sexes = array(
+15 -4
src/applications/people/storage/user/PhabricatorUser.php
··· 45 45 46 46 protected function readField($field) { 47 47 switch ($field) { 48 - case 'profileImagePHID': 49 - return nonempty( 50 - $this->profileImagePHID, 51 - PhabricatorEnv::getEnvConfig('user.default-profile-image-phid')); 52 48 case 'timezoneIdentifier': 53 49 // If the user hasn't set one, guess the server's time. 54 50 return nonempty( ··· 521 517 522 518 public static function validateUsername($username) { 523 519 return (bool)preg_match('/^[a-zA-Z0-9]+$/', $username); 520 + } 521 + 522 + public static function getDefaultProfileImageURI() { 523 + return celerity_get_resource_uri('/rsrc/image/avatar.png'); 524 + } 525 + 526 + public function loadProfileImageURI() { 527 + $src_phid = $this->getProfileImagePHID(); 528 + 529 + $file = id(new PhabricatorFile())->loadOneWhere('phid = %s', $src_phid); 530 + if ($file) { 531 + return $file->getBestURI(); 532 + } 533 + 534 + return self::getDefaultProfileImageURI(); 524 535 } 525 536 526 537 }
+2
src/applications/people/storage/user/__init__.php
··· 7 7 8 8 9 9 phutil_require_module('phabricator', 'aphront/writeguard'); 10 + phutil_require_module('phabricator', 'applications/files/storage/file'); 10 11 phutil_require_module('phabricator', 'applications/metamta/storage/mail'); 11 12 phutil_require_module('phabricator', 'applications/people/storage/base'); 12 13 phutil_require_module('phabricator', 'applications/people/storage/log'); ··· 14 15 phutil_require_module('phabricator', 'applications/phid/constants'); 15 16 phutil_require_module('phabricator', 'applications/phid/storage/phid'); 16 17 phutil_require_module('phabricator', 'applications/search/index/indexer/user'); 18 + phutil_require_module('phabricator', 'infrastructure/celerity/api'); 17 19 phutil_require_module('phabricator', 'infrastructure/env'); 18 20 phutil_require_module('phabricator', 'infrastructure/util/hash'); 19 21 phutil_require_module('phabricator', 'storage/qsprintf');
+3
src/applications/phid/handle/data/PhabricatorObjectHandleData.php
··· 169 169 $img_uri = idx($images, $user->getProfileImagePHID()); 170 170 if ($img_uri) { 171 171 $handle->setImageURI($img_uri); 172 + } else { 173 + $handle->setImageURI( 174 + PhabricatorUser::getDefaultProfileImageURI()); 172 175 } 173 176 } 174 177 $handles[$phid] = $handle;
+1
src/applications/phid/handle/data/__init__.php
··· 11 11 phutil_require_module('phabricator', 'applications/files/storage/file'); 12 12 phutil_require_module('phabricator', 'applications/maniphest/constants/owner'); 13 13 phutil_require_module('phabricator', 'applications/maniphest/constants/status'); 14 + phutil_require_module('phabricator', 'applications/people/storage/user'); 14 15 phutil_require_module('phabricator', 'applications/phid/constants'); 15 16 phutil_require_module('phabricator', 'applications/phid/handle'); 16 17 phutil_require_module('phabricator', 'applications/phid/handle/const/status');
+1 -1
src/applications/project/controller/profile/PhabricatorProjectProfileController.php
··· 49 49 if ($file) { 50 50 $picture = $file->getBestURI(); 51 51 } else { 52 - $picture = null; 52 + $picture = PhabricatorUser::getDefaultProfileImageURI(); 53 53 } 54 54 55 55 $members = mpull($project->loadAffiliations(), null, 'getUserPHID');
+1
src/applications/project/controller/profile/__init__.php
··· 12 12 phutil_require_module('phabricator', 'applications/files/storage/file'); 13 13 phutil_require_module('phabricator', 'applications/maniphest/query'); 14 14 phutil_require_module('phabricator', 'applications/maniphest/view/tasksummary'); 15 + phutil_require_module('phabricator', 'applications/people/storage/user'); 15 16 phutil_require_module('phabricator', 'applications/phid/handle/data'); 16 17 phutil_require_module('phabricator', 'applications/project/controller/base'); 17 18 phutil_require_module('phabricator', 'applications/project/storage/profile');
-5
src/applications/project/storage/profile/PhabricatorProjectProfile.php
··· 22 22 protected $blurb; 23 23 protected $profileImagePHID; 24 24 25 - public function getProfileImagePHID() { 26 - return nonempty( 27 - $this->profileImagePHID, 28 - PhabricatorEnv::getEnvConfig('user.default-profile-image-phid')); 29 - } 30 25 }
-3
src/applications/project/storage/profile/__init__.php
··· 7 7 8 8 9 9 phutil_require_module('phabricator', 'applications/project/storage/base'); 10 - phutil_require_module('phabricator', 'infrastructure/env'); 11 - 12 - phutil_require_module('phutil', 'utils'); 13 10 14 11 15 12 phutil_require_source('PhabricatorProjectProfile.php');
webroot/rsrc/image/avatar.png

This is a binary file and will not be displayed.