Skip to content

Commit 1520065

Browse files
author
epriestley
committedFeb 10, 2014
Migrate project blurb/description to standard custom field storage
Summary: Ref T4379. Major goal here is to remove `ProjectProfile` so all edits use ApplicationTransactions. This also makes things more flexible, allowing users to disable this field if they don't like it. Test Plan: Ran migration, verified data survived, edited/created projects, reordered fields. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T4379 Differential Revision: https://secure.phabricator.com/D8182
1 parent 7c8a875 commit 1520065

9 files changed

+83
-54
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
$conn_w = id(new PhabricatorProject())->establishConnection('w');
4+
$table_name = id(new PhabricatorProjectCustomFieldStorage())->getTableName();
5+
6+
$rows = new LiskRawMigrationIterator($conn_w, 'project_profile');
7+
8+
echo "Migrating project descriptions to custom storage...\n";
9+
foreach ($rows as $row) {
10+
$phid = $row['projectPHID'];
11+
echo "Migrating {$phid}...\n";
12+
13+
$desc = $row['blurb'];
14+
if (strlen($desc)) {
15+
queryfx(
16+
$conn_w,
17+
'INSERT IGNORE INTO %T (objectPHID, fieldIndex, fieldValue)
18+
VALUES (%s, %s, %s)',
19+
$table_name,
20+
$phid,
21+
PhabricatorHash::digestForIndex('std:project:internal:description'),
22+
$desc);
23+
}
24+
}
25+
26+
echo "Done.\n";

‎src/__phutil_library_map__.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -1840,6 +1840,7 @@
18401840
'PhabricatorProjectCustomFieldStorage' => 'applications/project/storage/PhabricatorProjectCustomFieldStorage.php',
18411841
'PhabricatorProjectCustomFieldStringIndex' => 'applications/project/storage/PhabricatorProjectCustomFieldStringIndex.php',
18421842
'PhabricatorProjectDAO' => 'applications/project/storage/PhabricatorProjectDAO.php',
1843+
'PhabricatorProjectDescriptionField' => 'applications/project/customfield/PhabricatorProjectDescriptionField.php',
18431844
'PhabricatorProjectEditorTestCase' => 'applications/project/editor/__tests__/PhabricatorProjectEditorTestCase.php',
18441845
'PhabricatorProjectHistoryController' => 'applications/project/controller/PhabricatorProjectHistoryController.php',
18451846
'PhabricatorProjectListController' => 'applications/project/controller/PhabricatorProjectListController.php',
@@ -1855,6 +1856,7 @@
18551856
'PhabricatorProjectQuery' => 'applications/project/query/PhabricatorProjectQuery.php',
18561857
'PhabricatorProjectSearchEngine' => 'applications/project/query/PhabricatorProjectSearchEngine.php',
18571858
'PhabricatorProjectSearchIndexer' => 'applications/project/search/PhabricatorProjectSearchIndexer.php',
1859+
'PhabricatorProjectStandardCustomField' => 'applications/project/customfield/PhabricatorProjectStandardCustomField.php',
18581860
'PhabricatorProjectStatus' => 'applications/project/constants/PhabricatorProjectStatus.php',
18591861
'PhabricatorProjectTestDataGenerator' => 'applications/project/lipsum/PhabricatorProjectTestDataGenerator.php',
18601862
'PhabricatorProjectTransaction' => 'applications/project/storage/PhabricatorProjectTransaction.php',
@@ -4574,7 +4576,7 @@
45744576
'PhabricatorProjectConfigOptions' => 'PhabricatorApplicationConfigOptions',
45754577
'PhabricatorProjectConfiguredCustomField' =>
45764578
array(
4577-
0 => 'PhabricatorProjectCustomField',
4579+
0 => 'PhabricatorProjectStandardCustomField',
45784580
1 => 'PhabricatorStandardCustomFieldInterface',
45794581
),
45804582
'PhabricatorProjectController' => 'PhabricatorController',
@@ -4584,6 +4586,7 @@
45844586
'PhabricatorProjectCustomFieldStorage' => 'PhabricatorCustomFieldStorage',
45854587
'PhabricatorProjectCustomFieldStringIndex' => 'PhabricatorCustomFieldStringIndexStorage',
45864588
'PhabricatorProjectDAO' => 'PhabricatorLiskDAO',
4589+
'PhabricatorProjectDescriptionField' => 'PhabricatorProjectStandardCustomField',
45874590
'PhabricatorProjectEditorTestCase' => 'PhabricatorTestCase',
45884591
'PhabricatorProjectHistoryController' => 'PhabricatorProjectController',
45894592
'PhabricatorProjectListController' =>
@@ -4603,6 +4606,11 @@
46034606
'PhabricatorProjectQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
46044607
'PhabricatorProjectSearchEngine' => 'PhabricatorApplicationSearchEngine',
46054608
'PhabricatorProjectSearchIndexer' => 'PhabricatorSearchDocumentIndexer',
4609+
'PhabricatorProjectStandardCustomField' =>
4610+
array(
4611+
0 => 'PhabricatorProjectCustomField',
4612+
1 => 'PhabricatorStandardCustomFieldInterface',
4613+
),
46064614
'PhabricatorProjectTestDataGenerator' => 'PhabricatorTestDataGenerator',
46074615
'PhabricatorProjectTransaction' => 'PhabricatorApplicationTransaction',
46084616
'PhabricatorProjectTransactionEditor' => 'PhabricatorApplicationTransactionEditor',

‎src/applications/project/config/PhabricatorProjectConfigOptions.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ public function getDescription() {
1212
}
1313

1414
public function getOptions() {
15-
// This is intentionally blank for now, until we can move more Project
16-
// logic to custom fields.
17-
$default_fields = array();
15+
$default_fields = array(
16+
'std:project:internal:description' => true,
17+
);
1818

1919
foreach ($default_fields as $key => $enabled) {
2020
$default_fields[$key] = array(

‎src/applications/project/controller/PhabricatorProjectCreateController.php

+2-9
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,10 @@ public function processRequest() {
4040

4141
// TODO: Deal with name collision exceptions more gracefully.
4242

43-
$profile->setBlurb($request->getStr('blurb'));
44-
4543
if (!$errors) {
4644
$project->save();
4745
$profile->setProjectPHID($project->getPHID());
46+
$profile->setBlurb('');
4847
$profile->save();
4948

5049
if ($request->isAjax()) {
@@ -79,13 +78,7 @@ public function processRequest() {
7978
->setLabel(pht('Name'))
8079
->setName('name')
8180
->setValue($project->getName())
82-
->setError($e_name))
83-
->appendChild(
84-
id(new AphrontFormTextAreaControl())
85-
->setLabel(pht('Blurb'))
86-
->setName('blurb')
87-
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_SHORT)
88-
->setValue($profile->getBlurb()));
81+
->setError($e_name));
8982

9083
if ($request->isAjax()) {
9184
$dialog = id(new AphrontDialogView())

‎src/applications/project/controller/PhabricatorProjectProfileController.php

-7
Original file line numberDiff line numberDiff line change
@@ -271,13 +271,6 @@ private function buildPropertyListView(
271271
PhabricatorCustomField::ROLE_VIEW);
272272
$field_list->appendFieldsToPropertyList($project, $viewer, $view);
273273

274-
$view->addSectionHeader(pht('Description'));
275-
$view->addTextContent(
276-
PhabricatorMarkupEngine::renderOneObject(
277-
id(new PhabricatorMarkupOneOff())->setContent($profile->getBlurb()),
278-
'default',
279-
$viewer));
280-
281274
return $view;
282275
}
283276

‎src/applications/project/controller/PhabricatorProjectProfileEditController.php

+1-21
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,11 @@ public function processRequest() {
2121
PhabricatorPolicyCapability::CAN_VIEW,
2222
PhabricatorPolicyCapability::CAN_EDIT,
2323
))
24-
->needProfiles(true)
2524
->executeOne();
2625
if (!$project) {
2726
return new Aphront404Response();
2827
}
2928

30-
$profile = $project->getProfile();
31-
3229
$field_list = PhabricatorCustomField::getObjectFields(
3330
$project,
3431
PhabricatorCustomField::ROLE_EDIT);
@@ -42,15 +39,13 @@ public function processRequest() {
4239
$e_edit = null;
4340

4441
$v_name = $project->getName();
45-
$v_desc = $profile->getBlurb();
4642

4743
$validation_exception = null;
4844

4945
if ($request->isFormPost()) {
5046
$e_name = null;
5147

5248
$v_name = $request->getStr('name');
53-
$v_desc = $request->getStr('blurb');
5449
$v_view = $request->getStr('can_view');
5550
$v_edit = $request->getStr('can_edit');
5651
$v_join = $request->getStr('can_join');
@@ -86,13 +81,6 @@ public function processRequest() {
8681
try {
8782
$editor->applyTransactions($project, $xactions);
8883

89-
// TODO: Move this into a custom field.
90-
$profile->setBlurb($request->getStr('blurb'));
91-
if (!$profile->getProjectPHID()) {
92-
$profile->setProjectPHID($project->getPHID());
93-
}
94-
$profile->save();
95-
9684
return id(new AphrontRedirectResponse())->setURI($view_uri);
9785
} catch (PhabricatorApplicationTransactionValidationException $ex) {
9886
$validation_exception = $ex;
@@ -108,7 +96,6 @@ public function processRequest() {
10896

10997
$header_name = pht('Edit Project');
11098
$title = pht('Edit Project');
111-
$action = '/project/edit/'.$project->getID().'/';
11299

113100
$policies = id(new PhabricatorPolicyQuery())
114101
->setViewer($viewer)
@@ -117,20 +104,13 @@ public function processRequest() {
117104

118105
$form = new AphrontFormView();
119106
$form
120-
->setID('project-edit-form')
121107
->setUser($viewer)
122-
->setAction($action)
123108
->appendChild(
124109
id(new AphrontFormTextControl())
125110
->setLabel(pht('Name'))
126111
->setName('name')
127112
->setValue($v_name)
128-
->setError($e_name))
129-
->appendChild(
130-
id(new PhabricatorRemarkupControl())
131-
->setLabel(pht('Description'))
132-
->setName('blurb')
133-
->setValue($v_desc));
113+
->setError($e_name));
134114

135115
$field_list->appendFieldsToForm($form);
136116

Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
final class PhabricatorProjectConfiguredCustomField
4-
extends PhabricatorProjectCustomField
4+
extends PhabricatorProjectStandardCustomField
55
implements PhabricatorStandardCustomFieldInterface {
66

77
public function getStandardCustomFieldNamespace() {
@@ -16,16 +16,4 @@ public function createFields() {
1616
array()));
1717
}
1818

19-
public function newStorageObject() {
20-
return new PhabricatorProjectCustomFieldStorage();
21-
}
22-
23-
protected function newStringIndexStorage() {
24-
return new PhabricatorProjectCustomFieldStringIndex();
25-
}
26-
27-
protected function newNumericIndexStorage() {
28-
return new PhabricatorProjectCustomFieldNumericIndex();
29-
}
30-
3119
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
final class PhabricatorProjectDescriptionField
4+
extends PhabricatorProjectStandardCustomField {
5+
6+
public function createFields() {
7+
return PhabricatorStandardCustomField::buildStandardFields(
8+
$this,
9+
array(
10+
'description' => array(
11+
'name' => pht('Description'),
12+
'type' => 'remarkup',
13+
'description' => pht('Short project description.'),
14+
),
15+
));
16+
}
17+
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
abstract class PhabricatorProjectStandardCustomField
4+
extends PhabricatorProjectCustomField
5+
implements PhabricatorStandardCustomFieldInterface {
6+
7+
public function getStandardCustomFieldNamespace() {
8+
return 'project:internal';
9+
}
10+
11+
public function newStorageObject() {
12+
return new PhabricatorProjectCustomFieldStorage();
13+
}
14+
15+
protected function newStringIndexStorage() {
16+
return new PhabricatorProjectCustomFieldStringIndex();
17+
}
18+
19+
protected function newNumericIndexStorage() {
20+
return new PhabricatorProjectCustomFieldNumericIndex();
21+
}
22+
23+
}

0 commit comments

Comments
 (0)
Failed to load comments.