diff --git a/conf/default.conf.php b/conf/default.conf.php index 334e0a12b9..98b7d9ca7f 100644 --- a/conf/default.conf.php +++ b/conf/default.conf.php @@ -31,10 +31,6 @@ return array( // you through setting up Phabricator. 'phabricator.setup' => false, - // The default PHID for users who haven't uploaded a profile image. It should - // be 50x50px. - 'user.default-profile-image-phid' => 'PHID-FILE-4d61229816cfe6f2b2a3', - // -- IMPORTANT! Security! -------------------------------------------------- // // IMPORTANT: By default, Phabricator serves files from the same domain the diff --git a/src/applications/conduit/method/user/base/ConduitAPI_user_Method.php b/src/applications/conduit/method/user/base/ConduitAPI_user_Method.php index ec73278b95..c74029b021 100644 --- a/src/applications/conduit/method/user/base/ConduitAPI_user_Method.php +++ b/src/applications/conduit/method/user/base/ConduitAPI_user_Method.php @@ -22,20 +22,12 @@ abstract class ConduitAPI_user_Method extends ConduitAPIMethod { protected function buildUserInformationDictionary(PhabricatorUser $user) { - $src_phid = $user->getProfileImagePHID(); - $file = id(new PhabricatorFile())->loadOneWhere('phid = %s', $src_phid); - if ($file) { - $picture = $file->getBestURI(); - } else { - $picture = null; - } - return array( 'phid' => $user->getPHID(), 'userName' => $user->getUserName(), 'realName' => $user->getRealName(), 'email' => $user->getEmail(), - 'image' => $picture, + 'image' => $user->loadProfileImageURI(), 'uri' => PhabricatorEnv::getURI('/p/'.$user->getUsername().'/'), ); } diff --git a/src/applications/conduit/method/user/base/__init__.php b/src/applications/conduit/method/user/base/__init__.php index 1780cf774f..a91e4dcbd1 100644 --- a/src/applications/conduit/method/user/base/__init__.php +++ b/src/applications/conduit/method/user/base/__init__.php @@ -7,10 +7,7 @@ phutil_require_module('phabricator', 'applications/conduit/method/base'); -phutil_require_module('phabricator', 'applications/files/storage/file'); phutil_require_module('phabricator', 'infrastructure/env'); -phutil_require_module('phutil', 'utils'); - phutil_require_source('ConduitAPI_user_Method.php'); diff --git a/src/applications/people/controller/profile/PhabricatorPeopleProfileController.php b/src/applications/people/controller/profile/PhabricatorPeopleProfileController.php index 111795f2df..ff91c71758 100644 --- a/src/applications/people/controller/profile/PhabricatorPeopleProfileController.php +++ b/src/applications/people/controller/profile/PhabricatorPeopleProfileController.php @@ -116,13 +116,7 @@ final class PhabricatorPeopleProfileController throw new Exception("Unknown page '{$this->page}'!"); } - $src_phid = $user->getProfileImagePHID(); - $file = id(new PhabricatorFile())->loadOneWhere('phid = %s', $src_phid); - if ($file) { - $picture = $file->getBestURI(); - } else { - $picture = null; - } + $picture = $user->loadProfileImageURI(); $header = new PhabricatorProfileHeaderView(); $header diff --git a/src/applications/people/controller/profile/__init__.php b/src/applications/people/controller/profile/__init__.php index 110a677ab4..a4f50fdc45 100644 --- a/src/applications/people/controller/profile/__init__.php +++ b/src/applications/people/controller/profile/__init__.php @@ -10,7 +10,6 @@ phutil_require_module('phabricator', 'aphront/response/404'); phutil_require_module('phabricator', 'applications/auth/oauth/provider/base'); phutil_require_module('phabricator', 'applications/feed/builder/feed'); phutil_require_module('phabricator', 'applications/feed/query'); -phutil_require_module('phabricator', 'applications/files/storage/file'); phutil_require_module('phabricator', 'applications/markup/engine'); phutil_require_module('phabricator', 'applications/people/controller/base'); phutil_require_module('phabricator', 'applications/people/storage/profile'); diff --git a/src/applications/people/controller/settings/panels/profile/PhabricatorUserProfileSettingsPanelController.php b/src/applications/people/controller/settings/panels/profile/PhabricatorUserProfileSettingsPanelController.php index 8c8e75c859..4856a04d5a 100644 --- a/src/applications/people/controller/settings/panels/profile/PhabricatorUserProfileSettingsPanelController.php +++ b/src/applications/people/controller/settings/panels/profile/PhabricatorUserProfileSettingsPanelController.php @@ -107,14 +107,7 @@ final class PhabricatorUserProfileSettingsPanelController } } - $file = id(new PhabricatorFile())->loadOneWhere( - 'phid = %s', - $user->getProfileImagePHID()); - if ($file) { - $img_src = $file->getBestURI(); - } else { - $img_src = null; - } + $img_src = $user->loadProfileImageURI(); $profile_uri = PhabricatorEnv::getURI('/p/'.$user->getUsername().'/'); $sexes = array( diff --git a/src/applications/people/storage/user/PhabricatorUser.php b/src/applications/people/storage/user/PhabricatorUser.php index b5d495ac53..4612b0456a 100644 --- a/src/applications/people/storage/user/PhabricatorUser.php +++ b/src/applications/people/storage/user/PhabricatorUser.php @@ -45,10 +45,6 @@ final class PhabricatorUser extends PhabricatorUserDAO { protected function readField($field) { switch ($field) { - case 'profileImagePHID': - return nonempty( - $this->profileImagePHID, - PhabricatorEnv::getEnvConfig('user.default-profile-image-phid')); case 'timezoneIdentifier': // If the user hasn't set one, guess the server's time. return nonempty( @@ -523,4 +519,19 @@ EOBODY; return (bool)preg_match('/^[a-zA-Z0-9]+$/', $username); } + public static function getDefaultProfileImageURI() { + return celerity_get_resource_uri('/rsrc/image/avatar.png'); + } + + public function loadProfileImageURI() { + $src_phid = $this->getProfileImagePHID(); + + $file = id(new PhabricatorFile())->loadOneWhere('phid = %s', $src_phid); + if ($file) { + return $file->getBestURI(); + } + + return self::getDefaultProfileImageURI(); + } + } diff --git a/src/applications/people/storage/user/__init__.php b/src/applications/people/storage/user/__init__.php index 910e09c634..3201c0f2e1 100644 --- a/src/applications/people/storage/user/__init__.php +++ b/src/applications/people/storage/user/__init__.php @@ -7,6 +7,7 @@ phutil_require_module('phabricator', 'aphront/writeguard'); +phutil_require_module('phabricator', 'applications/files/storage/file'); phutil_require_module('phabricator', 'applications/metamta/storage/mail'); phutil_require_module('phabricator', 'applications/people/storage/base'); phutil_require_module('phabricator', 'applications/people/storage/log'); @@ -14,6 +15,7 @@ phutil_require_module('phabricator', 'applications/people/storage/preferences'); phutil_require_module('phabricator', 'applications/phid/constants'); phutil_require_module('phabricator', 'applications/phid/storage/phid'); phutil_require_module('phabricator', 'applications/search/index/indexer/user'); +phutil_require_module('phabricator', 'infrastructure/celerity/api'); phutil_require_module('phabricator', 'infrastructure/env'); phutil_require_module('phabricator', 'infrastructure/util/hash'); phutil_require_module('phabricator', 'storage/qsprintf'); diff --git a/src/applications/phid/handle/data/PhabricatorObjectHandleData.php b/src/applications/phid/handle/data/PhabricatorObjectHandleData.php index a50a106b4d..de1ca5f562 100644 --- a/src/applications/phid/handle/data/PhabricatorObjectHandleData.php +++ b/src/applications/phid/handle/data/PhabricatorObjectHandleData.php @@ -169,6 +169,9 @@ final class PhabricatorObjectHandleData { $img_uri = idx($images, $user->getProfileImagePHID()); if ($img_uri) { $handle->setImageURI($img_uri); + } else { + $handle->setImageURI( + PhabricatorUser::getDefaultProfileImageURI()); } } $handles[$phid] = $handle; diff --git a/src/applications/phid/handle/data/__init__.php b/src/applications/phid/handle/data/__init__.php index 3cfb40dbf3..c2df9169cd 100644 --- a/src/applications/phid/handle/data/__init__.php +++ b/src/applications/phid/handle/data/__init__.php @@ -11,6 +11,7 @@ phutil_require_module('arcanist', 'differential/constants/revisionstatus'); phutil_require_module('phabricator', 'applications/files/storage/file'); phutil_require_module('phabricator', 'applications/maniphest/constants/owner'); phutil_require_module('phabricator', 'applications/maniphest/constants/status'); +phutil_require_module('phabricator', 'applications/people/storage/user'); phutil_require_module('phabricator', 'applications/phid/constants'); phutil_require_module('phabricator', 'applications/phid/handle'); phutil_require_module('phabricator', 'applications/phid/handle/const/status'); diff --git a/src/applications/project/controller/profile/PhabricatorProjectProfileController.php b/src/applications/project/controller/profile/PhabricatorProjectProfileController.php index 22c03f7a08..9a7528810d 100644 --- a/src/applications/project/controller/profile/PhabricatorProjectProfileController.php +++ b/src/applications/project/controller/profile/PhabricatorProjectProfileController.php @@ -49,7 +49,7 @@ final class PhabricatorProjectProfileController if ($file) { $picture = $file->getBestURI(); } else { - $picture = null; + $picture = PhabricatorUser::getDefaultProfileImageURI(); } $members = mpull($project->loadAffiliations(), null, 'getUserPHID'); diff --git a/src/applications/project/controller/profile/__init__.php b/src/applications/project/controller/profile/__init__.php index 8447952294..88f55e9312 100644 --- a/src/applications/project/controller/profile/__init__.php +++ b/src/applications/project/controller/profile/__init__.php @@ -12,6 +12,7 @@ phutil_require_module('phabricator', 'applications/feed/query'); phutil_require_module('phabricator', 'applications/files/storage/file'); phutil_require_module('phabricator', 'applications/maniphest/query'); phutil_require_module('phabricator', 'applications/maniphest/view/tasksummary'); +phutil_require_module('phabricator', 'applications/people/storage/user'); phutil_require_module('phabricator', 'applications/phid/handle/data'); phutil_require_module('phabricator', 'applications/project/controller/base'); phutil_require_module('phabricator', 'applications/project/storage/profile'); diff --git a/src/applications/project/storage/profile/PhabricatorProjectProfile.php b/src/applications/project/storage/profile/PhabricatorProjectProfile.php index f14d070138..2fc6d0403c 100644 --- a/src/applications/project/storage/profile/PhabricatorProjectProfile.php +++ b/src/applications/project/storage/profile/PhabricatorProjectProfile.php @@ -22,9 +22,4 @@ final class PhabricatorProjectProfile extends PhabricatorProjectDAO { protected $blurb; protected $profileImagePHID; - public function getProfileImagePHID() { - return nonempty( - $this->profileImagePHID, - PhabricatorEnv::getEnvConfig('user.default-profile-image-phid')); - } } diff --git a/src/applications/project/storage/profile/__init__.php b/src/applications/project/storage/profile/__init__.php index 7049de11cc..da02c73032 100644 --- a/src/applications/project/storage/profile/__init__.php +++ b/src/applications/project/storage/profile/__init__.php @@ -7,9 +7,6 @@ phutil_require_module('phabricator', 'applications/project/storage/base'); -phutil_require_module('phabricator', 'infrastructure/env'); - -phutil_require_module('phutil', 'utils'); phutil_require_source('PhabricatorProjectProfile.php'); diff --git a/webroot/rsrc/image/avatar.png b/webroot/rsrc/image/avatar.png new file mode 100644 index 0000000000..755d19cd2e Binary files /dev/null and b/webroot/rsrc/image/avatar.png differ