diff --git a/resources/sql/autopatches/20140210.projcfield.2.piccol.sql b/resources/sql/autopatches/20140210.projcfield.2.piccol.sql new file mode 100644 index 0000000000..08e1c11ed8 --- /dev/null +++ b/resources/sql/autopatches/20140210.projcfield.2.piccol.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_project.project + ADD profileImagePHID VARCHAR(64) COLLATE utf8_bin; diff --git a/resources/sql/autopatches/20140210.projcfield.3.picmig.sql b/resources/sql/autopatches/20140210.projcfield.3.picmig.sql new file mode 100644 index 0000000000..0b9814035e --- /dev/null +++ b/resources/sql/autopatches/20140210.projcfield.3.picmig.sql @@ -0,0 +1,4 @@ +UPDATE {$NAMESPACE}_project.project proj, + {$NAMESPACE}_project.project_profile profile + SET proj.profileImagePHID = profile.profileImagePHID + WHERE proj.phid = profile.projectPHID; diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index f28ae65ce7..643935d746 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1849,7 +1849,6 @@ phutil_register_library_map(array( 'PhabricatorProjectNameCollisionException' => 'applications/project/exception/PhabricatorProjectNameCollisionException.php', 'PhabricatorProjectPHIDTypeColumn' => 'applications/project/phid/PhabricatorProjectPHIDTypeColumn.php', 'PhabricatorProjectPHIDTypeProject' => 'applications/project/phid/PhabricatorProjectPHIDTypeProject.php', - 'PhabricatorProjectProfile' => 'applications/project/storage/PhabricatorProjectProfile.php', 'PhabricatorProjectProfileController' => 'applications/project/controller/PhabricatorProjectProfileController.php', 'PhabricatorProjectProfileEditController' => 'applications/project/controller/PhabricatorProjectProfileEditController.php', 'PhabricatorProjectProfilePictureController' => 'applications/project/controller/PhabricatorProjectProfilePictureController.php', @@ -4599,7 +4598,6 @@ phutil_register_library_map(array( 'PhabricatorProjectNameCollisionException' => 'Exception', 'PhabricatorProjectPHIDTypeColumn' => 'PhabricatorPHIDType', 'PhabricatorProjectPHIDTypeProject' => 'PhabricatorPHIDType', - 'PhabricatorProjectProfile' => 'PhabricatorProjectDAO', 'PhabricatorProjectProfileController' => 'PhabricatorProjectController', 'PhabricatorProjectProfileEditController' => 'PhabricatorProjectController', 'PhabricatorProjectProfilePictureController' => 'PhabricatorProjectController', diff --git a/src/applications/project/controller/PhabricatorProjectArchiveController.php b/src/applications/project/controller/PhabricatorProjectArchiveController.php index 8ac59f4c79..5081e59cfa 100644 --- a/src/applications/project/controller/PhabricatorProjectArchiveController.php +++ b/src/applications/project/controller/PhabricatorProjectArchiveController.php @@ -21,7 +21,6 @@ final class PhabricatorProjectArchiveController PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, )) - ->needProfiles(true) ->executeOne(); if (!$project) { return new Aphront404Response(); diff --git a/src/applications/project/controller/PhabricatorProjectCreateController.php b/src/applications/project/controller/PhabricatorProjectCreateController.php index f91d6c2b31..d5286ab4c7 100644 --- a/src/applications/project/controller/PhabricatorProjectCreateController.php +++ b/src/applications/project/controller/PhabricatorProjectCreateController.php @@ -13,7 +13,6 @@ final class PhabricatorProjectCreateController ProjectCapabilityCreateProjects::CAPABILITY); $project = PhabricatorProject::initializeNewProject($user); - $profile = new PhabricatorProjectProfile(); $e_name = true; $errors = array(); @@ -42,9 +41,6 @@ final class PhabricatorProjectCreateController if (!$errors) { $project->save(); - $profile->setProjectPHID($project->getPHID()); - $profile->setBlurb(''); - $profile->save(); if ($request->isAjax()) { return id(new AphrontAjaxResponse()) diff --git a/src/applications/project/controller/PhabricatorProjectProfileController.php b/src/applications/project/controller/PhabricatorProjectProfileController.php index 203f8f0977..f8981f210d 100644 --- a/src/applications/project/controller/PhabricatorProjectProfileController.php +++ b/src/applications/project/controller/PhabricatorProjectProfileController.php @@ -23,18 +23,17 @@ final class PhabricatorProjectProfileController ->setViewer($user) ->withIDs(array($this->id)) ->needMembers(true) - ->needProfiles(true) + ->needImages(true) ->executeOne(); if (!$project) { return new Aphront404Response(); } - $profile = $project->getProfile(); - $picture = $profile->getProfileImageURI(); + $picture = $project->getProfileImageURI(); require_celerity_resource('phabricator-profile-css'); - $tasks = $this->renderTasksPage($project, $profile); + $tasks = $this->renderTasksPage($project); $query = new PhabricatorFeedQuery(); $query->setFilterPHIDs( @@ -62,9 +61,8 @@ final class PhabricatorProjectProfileController $header->setStatus('policy-noone', '', pht('Archived')); } - $actions = $this->buildActionListView($project); - $properties = $this->buildPropertyListView($project, $profile, $actions); + $properties = $this->buildPropertyListView($project, $actions); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb($project->getName()) @@ -86,9 +84,7 @@ final class PhabricatorProjectProfileController )); } - private function renderFeedPage( - PhabricatorProject $project, - PhabricatorProjectProfile $profile) { + private function renderFeedPage(PhabricatorProject $project) { $query = new PhabricatorFeedQuery(); $query->setFilterPHIDs(array($project->getPHID())); @@ -117,9 +113,7 @@ final class PhabricatorProjectProfileController } - private function renderTasksPage( - PhabricatorProject $project, - PhabricatorProjectProfile $profile) { + private function renderTasksPage(PhabricatorProject $project) { $user = $this->getRequest()->getUser(); @@ -244,7 +238,6 @@ final class PhabricatorProjectProfileController private function buildPropertyListView( PhabricatorProject $project, - PhabricatorProjectProfile $profile, PhabricatorActionListView $actions) { $request = $this->getRequest(); $viewer = $request->getUser(); diff --git a/src/applications/project/controller/PhabricatorProjectProfilePictureController.php b/src/applications/project/controller/PhabricatorProjectProfilePictureController.php index 8c2145f9f4..a523945792 100644 --- a/src/applications/project/controller/PhabricatorProjectProfilePictureController.php +++ b/src/applications/project/controller/PhabricatorProjectProfilePictureController.php @@ -16,7 +16,6 @@ final class PhabricatorProjectProfilePictureController $project = id(new PhabricatorProjectQuery()) ->setViewer($viewer) ->withIDs(array($this->id)) - ->needProfiles(true) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, @@ -75,14 +74,13 @@ final class PhabricatorProjectProfilePictureController } if (!$errors) { - $profile = $project->getProfile(); if ($is_default) { - $profile->setProfileImagePHID(null); + $project->setProfileImagePHID(null); } else { - $profile->setProfileImagePHID($xformed->getPHID()); + $project->setProfileImagePHID($xformed->getPHID()); $xformed->attachToObject($viewer, $project->getPHID()); } - $profile->save(); + $project->save(); return id(new AphrontRedirectResponse())->setURI($project_uri); } } @@ -99,7 +97,7 @@ final class PhabricatorProjectProfilePictureController $images = array(); - $current = $project->getProfile()->getProfileImagePHID(); + $current = $project->getProfileImagePHID(); $has_current = false; if ($current) { $files = id(new PhabricatorFileQuery()) diff --git a/src/applications/project/lipsum/PhabricatorProjectTestDataGenerator.php b/src/applications/project/lipsum/PhabricatorProjectTestDataGenerator.php index bb38015778..22e5b698ba 100644 --- a/src/applications/project/lipsum/PhabricatorProjectTestDataGenerator.php +++ b/src/applications/project/lipsum/PhabricatorProjectTestDataGenerator.php @@ -37,11 +37,6 @@ final class PhabricatorProjectTestDataGenerator ->setContentSource(PhabricatorContentSource::newConsoleSource()) ->applyTransactions($project, $this->xactions); - $profile = id(new PhabricatorProjectProfile()) - ->setBlurb($this->generateDescription()) - ->setProjectPHID($project->getPHID()) - ->save(); - return $project->save(); } diff --git a/src/applications/project/query/PhabricatorProjectQuery.php b/src/applications/project/query/PhabricatorProjectQuery.php index 7b18adf563..52dfeb5368 100644 --- a/src/applications/project/query/PhabricatorProjectQuery.php +++ b/src/applications/project/query/PhabricatorProjectQuery.php @@ -17,7 +17,7 @@ final class PhabricatorProjectQuery const STATUS_ARCHIVED = 'status-archived'; private $needMembers; - private $needProfiles; + private $needImages; public function withIDs(array $ids) { $this->ids = $ids; @@ -54,8 +54,8 @@ final class PhabricatorProjectQuery return $this; } - public function needProfiles($need_profiles) { - $this->needProfiles = $need_profiles; + public function needImages($need_images) { + $this->needImages = $need_images; return $this; } @@ -126,49 +126,27 @@ final class PhabricatorProjectQuery } protected function didFilterPage(array $projects) { - if ($this->needProfiles) { - $profiles = id(new PhabricatorProjectProfile())->loadAllWhere( - 'projectPHID IN (%Ls)', - mpull($projects, 'getPHID')); - $profiles = mpull($profiles, null, 'getProjectPHID'); - + if ($this->needImages) { $default = null; - if ($profiles) { - $file_phids = mpull($profiles, 'getProfileImagePHID'); - $files = id(new PhabricatorFileQuery()) - ->setParentQuery($this) - ->setViewer($this->getViewer()) - ->withPHIDs($file_phids) - ->execute(); - $files = mpull($files, null, 'getPHID'); - foreach ($profiles as $profile) { - $file = idx($files, $profile->getProfileImagePHID()); - if (!$file) { - if (!$default) { - $default = PhabricatorFile::loadBuiltin( - $this->getViewer(), - 'project.png'); - } - $file = $default; - } - $profile->attachProfileImageFile($file); - } - } - + $file_phids = mpull($projects, 'getProfileImagePHID'); + $files = id(new PhabricatorFileQuery()) + ->setParentQuery($this) + ->setViewer($this->getViewer()) + ->withPHIDs($file_phids) + ->execute(); + $files = mpull($files, null, 'getPHID'); foreach ($projects as $project) { - $profile = idx($profiles, $project->getPHID()); - if (!$profile) { + $file = idx($files, $project->getProfileImagePHID()); + if (!$file) { if (!$default) { $default = PhabricatorFile::loadBuiltin( $this->getViewer(), 'project.png'); } - $profile = id(new PhabricatorProjectProfile()) - ->setProjectPHID($project->getPHID()) - ->attachProfileImageFile($default); + $file = $default; } - $project->attachProfile($profile); + $project->attachProfileImageFile($file); } } diff --git a/src/applications/project/storage/PhabricatorProject.php b/src/applications/project/storage/PhabricatorProject.php index b7dd56ecd5..560f2e0797 100644 --- a/src/applications/project/storage/PhabricatorProject.php +++ b/src/applications/project/storage/PhabricatorProject.php @@ -12,6 +12,7 @@ final class PhabricatorProject extends PhabricatorProjectDAO protected $authorPHID; protected $subprojectPHIDs = array(); protected $phrictionSlug; + protected $profileImagePHID; protected $viewPolicy; protected $editPolicy; @@ -19,8 +20,8 @@ final class PhabricatorProject extends PhabricatorProjectDAO private $memberPHIDs = self::ATTACHABLE; private $sparseMembers = self::ATTACHABLE; - private $profile = self::ATTACHABLE; private $customFields = self::ATTACHABLE; + private $profileImageFile = self::ATTACHABLE; public static function initializeNewProject(PhabricatorUser $actor) { return id(new PhabricatorProject()) @@ -113,15 +114,6 @@ final class PhabricatorProject extends PhabricatorProjectDAO PhabricatorProjectPHIDTypeProject::TYPECONST); } - public function getProfile() { - return $this->assertAttached($this->profile); - } - - public function attachProfile(PhabricatorProjectProfile $profile) { - $this->profile = $profile; - return $this; - } - public function attachMemberPHIDs(array $phids) { $this->memberPHIDs = $phids; return $this; @@ -153,6 +145,19 @@ final class PhabricatorProject extends PhabricatorProjectDAO return ($this->getStatus() == PhabricatorProjectStatus::STATUS_ARCHIVED); } + public function getProfileImageURI() { + return $this->getProfileImageFile()->getBestURI(); + } + + public function attachProfileImageFile(PhabricatorFile $file) { + $this->profileImageFile = $file; + return $this; + } + + public function getProfileImageFile() { + return $this->assertAttached($this->profileImageFile); + } + /* -( PhabricatorSubscribableInterface )----------------------------------- */ diff --git a/src/applications/project/storage/PhabricatorProjectProfile.php b/src/applications/project/storage/PhabricatorProjectProfile.php deleted file mode 100644 index 57c835761f..0000000000 --- a/src/applications/project/storage/PhabricatorProjectProfile.php +++ /dev/null @@ -1,24 +0,0 @@ -getProfileImageFile()->getBestURI(); - } - - public function attachProfileImageFile(PhabricatorFile $file) { - $this->profileImageFile = $file; - return $this; - } - - public function getProfileImageFile() { - return $this->assertAttached($this->profileImageFile); - } - -} diff --git a/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php b/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php index 74c2f38d96..d80dd297d8 100644 --- a/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php +++ b/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php @@ -286,7 +286,7 @@ final class PhabricatorTypeaheadCommonDatasourceController $projs = id(new PhabricatorProjectQuery()) ->setViewer($viewer) ->withStatus(PhabricatorProjectQuery::STATUS_OPEN) - ->needProfiles(true) + ->needImages(true) ->execute(); foreach ($projs as $proj) { $proj_result = id(new PhabricatorTypeaheadResult()) @@ -295,8 +295,7 @@ final class PhabricatorTypeaheadCommonDatasourceController ->setURI('/project/view/'.$proj->getID().'/') ->setPHID($proj->getPHID()); - $prof = $proj->getProfile(); - $proj_result->setImageURI($prof->getProfileImageURI()); + $proj_result->setImageURI($proj->getProfileImageURI()); $results[] = $proj_result; }