Page MenuHomePhabricator

D8183.diff
No OneTemporary

D8183.diff

Index: resources/sql/autopatches/20140210.projcfield.2.piccol.sql
===================================================================
--- /dev/null
+++ resources/sql/autopatches/20140210.projcfield.2.piccol.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_project.project
+ ADD profileImagePHID VARCHAR(64) COLLATE utf8_bin;
Index: resources/sql/autopatches/20140210.projcfield.3.picmig.sql
===================================================================
--- /dev/null
+++ 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;
Index: src/__phutil_library_map__.php
===================================================================
--- src/__phutil_library_map__.php
+++ src/__phutil_library_map__.php
@@ -1849,7 +1849,6 @@
'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 @@
'PhabricatorProjectNameCollisionException' => 'Exception',
'PhabricatorProjectPHIDTypeColumn' => 'PhabricatorPHIDType',
'PhabricatorProjectPHIDTypeProject' => 'PhabricatorPHIDType',
- 'PhabricatorProjectProfile' => 'PhabricatorProjectDAO',
'PhabricatorProjectProfileController' => 'PhabricatorProjectController',
'PhabricatorProjectProfileEditController' => 'PhabricatorProjectController',
'PhabricatorProjectProfilePictureController' => 'PhabricatorProjectController',
Index: src/applications/project/controller/PhabricatorProjectArchiveController.php
===================================================================
--- src/applications/project/controller/PhabricatorProjectArchiveController.php
+++ src/applications/project/controller/PhabricatorProjectArchiveController.php
@@ -21,7 +21,6 @@
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
))
- ->needProfiles(true)
->executeOne();
if (!$project) {
return new Aphront404Response();
Index: src/applications/project/controller/PhabricatorProjectCreateController.php
===================================================================
--- src/applications/project/controller/PhabricatorProjectCreateController.php
+++ src/applications/project/controller/PhabricatorProjectCreateController.php
@@ -13,7 +13,6 @@
ProjectCapabilityCreateProjects::CAPABILITY);
$project = PhabricatorProject::initializeNewProject($user);
- $profile = new PhabricatorProjectProfile();
$e_name = true;
$errors = array();
@@ -42,9 +41,6 @@
if (!$errors) {
$project->save();
- $profile->setProjectPHID($project->getPHID());
- $profile->setBlurb('');
- $profile->save();
if ($request->isAjax()) {
return id(new AphrontAjaxResponse())
Index: src/applications/project/controller/PhabricatorProjectProfileController.php
===================================================================
--- src/applications/project/controller/PhabricatorProjectProfileController.php
+++ src/applications/project/controller/PhabricatorProjectProfileController.php
@@ -23,18 +23,17 @@
->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 @@
$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 @@
));
}
- private function renderFeedPage(
- PhabricatorProject $project,
- PhabricatorProjectProfile $profile) {
+ private function renderFeedPage(PhabricatorProject $project) {
$query = new PhabricatorFeedQuery();
$query->setFilterPHIDs(array($project->getPHID()));
@@ -117,9 +113,7 @@
}
- private function renderTasksPage(
- PhabricatorProject $project,
- PhabricatorProjectProfile $profile) {
+ private function renderTasksPage(PhabricatorProject $project) {
$user = $this->getRequest()->getUser();
@@ -244,7 +238,6 @@
private function buildPropertyListView(
PhabricatorProject $project,
- PhabricatorProjectProfile $profile,
PhabricatorActionListView $actions) {
$request = $this->getRequest();
$viewer = $request->getUser();
Index: src/applications/project/controller/PhabricatorProjectProfilePictureController.php
===================================================================
--- src/applications/project/controller/PhabricatorProjectProfilePictureController.php
+++ src/applications/project/controller/PhabricatorProjectProfilePictureController.php
@@ -16,7 +16,6 @@
$project = id(new PhabricatorProjectQuery())
->setViewer($viewer)
->withIDs(array($this->id))
- ->needProfiles(true)
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
@@ -75,14 +74,13 @@
}
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 @@
$images = array();
- $current = $project->getProfile()->getProfileImagePHID();
+ $current = $project->getProfileImagePHID();
$has_current = false;
if ($current) {
$files = id(new PhabricatorFileQuery())
Index: src/applications/project/lipsum/PhabricatorProjectTestDataGenerator.php
===================================================================
--- src/applications/project/lipsum/PhabricatorProjectTestDataGenerator.php
+++ src/applications/project/lipsum/PhabricatorProjectTestDataGenerator.php
@@ -37,11 +37,6 @@
->setContentSource(PhabricatorContentSource::newConsoleSource())
->applyTransactions($project, $this->xactions);
- $profile = id(new PhabricatorProjectProfile())
- ->setBlurb($this->generateDescription())
- ->setProjectPHID($project->getPHID())
- ->save();
-
return $project->save();
}
Index: src/applications/project/query/PhabricatorProjectQuery.php
===================================================================
--- src/applications/project/query/PhabricatorProjectQuery.php
+++ src/applications/project/query/PhabricatorProjectQuery.php
@@ -17,7 +17,7 @@
const STATUS_ARCHIVED = 'status-archived';
private $needMembers;
- private $needProfiles;
+ private $needImages;
public function withIDs(array $ids) {
$this->ids = $ids;
@@ -54,8 +54,8 @@
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 @@
}
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);
}
}
Index: src/applications/project/storage/PhabricatorProject.php
===================================================================
--- src/applications/project/storage/PhabricatorProject.php
+++ src/applications/project/storage/PhabricatorProject.php
@@ -12,6 +12,7 @@
protected $authorPHID;
protected $subprojectPHIDs = array();
protected $phrictionSlug;
+ protected $profileImagePHID;
protected $viewPolicy;
protected $editPolicy;
@@ -19,8 +20,8 @@
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 @@
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 @@
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 )----------------------------------- */
Index: src/applications/project/storage/PhabricatorProjectProfile.php
===================================================================
--- src/applications/project/storage/PhabricatorProjectProfile.php
+++ /dev/null
@@ -1,24 +0,0 @@
-<?php
-
-final class PhabricatorProjectProfile extends PhabricatorProjectDAO {
-
- protected $projectPHID;
- protected $blurb;
- protected $profileImagePHID;
-
- private $profileImageFile = self::ATTACHABLE;
-
- 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);
- }
-
-}
Index: src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php
===================================================================
--- src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php
+++ src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php
@@ -286,7 +286,7 @@
$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 @@
->setURI('/project/view/'.$proj->getID().'/')
->setPHID($proj->getPHID());
- $prof = $proj->getProfile();
- $proj_result->setImageURI($prof->getProfileImageURI());
+ $proj_result->setImageURI($proj->getProfileImageURI());
$results[] = $proj_result;
}

File Metadata

Mime Type
text/plain
Expires
Sun, Dec 29, 4:57 PM (9 h, 27 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6943115
Default Alt Text
D8183.diff (13 KB)

Event Timeline