Page MenuHomePhabricator

D8182.diff
No OneTemporary

D8182.diff

Index: resources/sql/autopatches/20140210.projcfield.1.blurb.php
===================================================================
--- /dev/null
+++ resources/sql/autopatches/20140210.projcfield.1.blurb.php
@@ -0,0 +1,26 @@
+<?php
+
+$conn_w = id(new PhabricatorProject())->establishConnection('w');
+$table_name = id(new PhabricatorProjectCustomFieldStorage())->getTableName();
+
+$rows = new LiskRawMigrationIterator($conn_w, 'project_profile');
+
+echo "Migrating project descriptions to custom storage...\n";
+foreach ($rows as $row) {
+ $phid = $row['projectPHID'];
+ echo "Migrating {$phid}...\n";
+
+ $desc = $row['blurb'];
+ if (strlen($desc)) {
+ queryfx(
+ $conn_w,
+ 'INSERT IGNORE INTO %T (objectPHID, fieldIndex, fieldValue)
+ VALUES (%s, %s, %s)',
+ $table_name,
+ $phid,
+ PhabricatorHash::digestForIndex('std:project:internal:description'),
+ $desc);
+ }
+}
+
+echo "Done.\n";
Index: src/__phutil_library_map__.php
===================================================================
--- src/__phutil_library_map__.php
+++ src/__phutil_library_map__.php
@@ -1840,6 +1840,7 @@
'PhabricatorProjectCustomFieldStorage' => 'applications/project/storage/PhabricatorProjectCustomFieldStorage.php',
'PhabricatorProjectCustomFieldStringIndex' => 'applications/project/storage/PhabricatorProjectCustomFieldStringIndex.php',
'PhabricatorProjectDAO' => 'applications/project/storage/PhabricatorProjectDAO.php',
+ 'PhabricatorProjectDescriptionField' => 'applications/project/customfield/PhabricatorProjectDescriptionField.php',
'PhabricatorProjectEditorTestCase' => 'applications/project/editor/__tests__/PhabricatorProjectEditorTestCase.php',
'PhabricatorProjectHistoryController' => 'applications/project/controller/PhabricatorProjectHistoryController.php',
'PhabricatorProjectListController' => 'applications/project/controller/PhabricatorProjectListController.php',
@@ -1855,6 +1856,7 @@
'PhabricatorProjectQuery' => 'applications/project/query/PhabricatorProjectQuery.php',
'PhabricatorProjectSearchEngine' => 'applications/project/query/PhabricatorProjectSearchEngine.php',
'PhabricatorProjectSearchIndexer' => 'applications/project/search/PhabricatorProjectSearchIndexer.php',
+ 'PhabricatorProjectStandardCustomField' => 'applications/project/customfield/PhabricatorProjectStandardCustomField.php',
'PhabricatorProjectStatus' => 'applications/project/constants/PhabricatorProjectStatus.php',
'PhabricatorProjectTestDataGenerator' => 'applications/project/lipsum/PhabricatorProjectTestDataGenerator.php',
'PhabricatorProjectTransaction' => 'applications/project/storage/PhabricatorProjectTransaction.php',
@@ -4574,7 +4576,7 @@
'PhabricatorProjectConfigOptions' => 'PhabricatorApplicationConfigOptions',
'PhabricatorProjectConfiguredCustomField' =>
array(
- 0 => 'PhabricatorProjectCustomField',
+ 0 => 'PhabricatorProjectStandardCustomField',
1 => 'PhabricatorStandardCustomFieldInterface',
),
'PhabricatorProjectController' => 'PhabricatorController',
@@ -4584,6 +4586,7 @@
'PhabricatorProjectCustomFieldStorage' => 'PhabricatorCustomFieldStorage',
'PhabricatorProjectCustomFieldStringIndex' => 'PhabricatorCustomFieldStringIndexStorage',
'PhabricatorProjectDAO' => 'PhabricatorLiskDAO',
+ 'PhabricatorProjectDescriptionField' => 'PhabricatorProjectStandardCustomField',
'PhabricatorProjectEditorTestCase' => 'PhabricatorTestCase',
'PhabricatorProjectHistoryController' => 'PhabricatorProjectController',
'PhabricatorProjectListController' =>
@@ -4603,6 +4606,11 @@
'PhabricatorProjectQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorProjectSearchEngine' => 'PhabricatorApplicationSearchEngine',
'PhabricatorProjectSearchIndexer' => 'PhabricatorSearchDocumentIndexer',
+ 'PhabricatorProjectStandardCustomField' =>
+ array(
+ 0 => 'PhabricatorProjectCustomField',
+ 1 => 'PhabricatorStandardCustomFieldInterface',
+ ),
'PhabricatorProjectTestDataGenerator' => 'PhabricatorTestDataGenerator',
'PhabricatorProjectTransaction' => 'PhabricatorApplicationTransaction',
'PhabricatorProjectTransactionEditor' => 'PhabricatorApplicationTransactionEditor',
Index: src/applications/project/config/PhabricatorProjectConfigOptions.php
===================================================================
--- src/applications/project/config/PhabricatorProjectConfigOptions.php
+++ src/applications/project/config/PhabricatorProjectConfigOptions.php
@@ -12,9 +12,9 @@
}
public function getOptions() {
- // This is intentionally blank for now, until we can move more Project
- // logic to custom fields.
- $default_fields = array();
+ $default_fields = array(
+ 'std:project:internal:description' => true,
+ );
foreach ($default_fields as $key => $enabled) {
$default_fields[$key] = array(
Index: src/applications/project/controller/PhabricatorProjectCreateController.php
===================================================================
--- src/applications/project/controller/PhabricatorProjectCreateController.php
+++ src/applications/project/controller/PhabricatorProjectCreateController.php
@@ -40,11 +40,10 @@
// TODO: Deal with name collision exceptions more gracefully.
- $profile->setBlurb($request->getStr('blurb'));
-
if (!$errors) {
$project->save();
$profile->setProjectPHID($project->getPHID());
+ $profile->setBlurb('');
$profile->save();
if ($request->isAjax()) {
@@ -79,13 +78,7 @@
->setLabel(pht('Name'))
->setName('name')
->setValue($project->getName())
- ->setError($e_name))
- ->appendChild(
- id(new AphrontFormTextAreaControl())
- ->setLabel(pht('Blurb'))
- ->setName('blurb')
- ->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_SHORT)
- ->setValue($profile->getBlurb()));
+ ->setError($e_name));
if ($request->isAjax()) {
$dialog = id(new AphrontDialogView())
Index: src/applications/project/controller/PhabricatorProjectProfileController.php
===================================================================
--- src/applications/project/controller/PhabricatorProjectProfileController.php
+++ src/applications/project/controller/PhabricatorProjectProfileController.php
@@ -271,13 +271,6 @@
PhabricatorCustomField::ROLE_VIEW);
$field_list->appendFieldsToPropertyList($project, $viewer, $view);
- $view->addSectionHeader(pht('Description'));
- $view->addTextContent(
- PhabricatorMarkupEngine::renderOneObject(
- id(new PhabricatorMarkupOneOff())->setContent($profile->getBlurb()),
- 'default',
- $viewer));
-
return $view;
}
Index: src/applications/project/controller/PhabricatorProjectProfileEditController.php
===================================================================
--- src/applications/project/controller/PhabricatorProjectProfileEditController.php
+++ src/applications/project/controller/PhabricatorProjectProfileEditController.php
@@ -21,14 +21,11 @@
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
))
- ->needProfiles(true)
->executeOne();
if (!$project) {
return new Aphront404Response();
}
- $profile = $project->getProfile();
-
$field_list = PhabricatorCustomField::getObjectFields(
$project,
PhabricatorCustomField::ROLE_EDIT);
@@ -42,7 +39,6 @@
$e_edit = null;
$v_name = $project->getName();
- $v_desc = $profile->getBlurb();
$validation_exception = null;
@@ -50,7 +46,6 @@
$e_name = null;
$v_name = $request->getStr('name');
- $v_desc = $request->getStr('blurb');
$v_view = $request->getStr('can_view');
$v_edit = $request->getStr('can_edit');
$v_join = $request->getStr('can_join');
@@ -86,13 +81,6 @@
try {
$editor->applyTransactions($project, $xactions);
- // TODO: Move this into a custom field.
- $profile->setBlurb($request->getStr('blurb'));
- if (!$profile->getProjectPHID()) {
- $profile->setProjectPHID($project->getPHID());
- }
- $profile->save();
-
return id(new AphrontRedirectResponse())->setURI($view_uri);
} catch (PhabricatorApplicationTransactionValidationException $ex) {
$validation_exception = $ex;
@@ -108,7 +96,6 @@
$header_name = pht('Edit Project');
$title = pht('Edit Project');
- $action = '/project/edit/'.$project->getID().'/';
$policies = id(new PhabricatorPolicyQuery())
->setViewer($viewer)
@@ -117,20 +104,13 @@
$form = new AphrontFormView();
$form
- ->setID('project-edit-form')
->setUser($viewer)
- ->setAction($action)
->appendChild(
id(new AphrontFormTextControl())
->setLabel(pht('Name'))
->setName('name')
->setValue($v_name)
- ->setError($e_name))
- ->appendChild(
- id(new PhabricatorRemarkupControl())
- ->setLabel(pht('Description'))
- ->setName('blurb')
- ->setValue($v_desc));
+ ->setError($e_name));
$field_list->appendFieldsToForm($form);
Index: src/applications/project/customfield/PhabricatorProjectConfiguredCustomField.php
===================================================================
--- src/applications/project/customfield/PhabricatorProjectConfiguredCustomField.php
+++ src/applications/project/customfield/PhabricatorProjectConfiguredCustomField.php
@@ -1,7 +1,7 @@
<?php
final class PhabricatorProjectConfiguredCustomField
- extends PhabricatorProjectCustomField
+ extends PhabricatorProjectStandardCustomField
implements PhabricatorStandardCustomFieldInterface {
public function getStandardCustomFieldNamespace() {
@@ -16,16 +16,4 @@
array()));
}
- public function newStorageObject() {
- return new PhabricatorProjectCustomFieldStorage();
- }
-
- protected function newStringIndexStorage() {
- return new PhabricatorProjectCustomFieldStringIndex();
- }
-
- protected function newNumericIndexStorage() {
- return new PhabricatorProjectCustomFieldNumericIndex();
- }
-
}
Index: src/applications/project/customfield/PhabricatorProjectDescriptionField.php
===================================================================
--- /dev/null
+++ src/applications/project/customfield/PhabricatorProjectDescriptionField.php
@@ -0,0 +1,18 @@
+<?php
+
+final class PhabricatorProjectDescriptionField
+ extends PhabricatorProjectStandardCustomField {
+
+ public function createFields() {
+ return PhabricatorStandardCustomField::buildStandardFields(
+ $this,
+ array(
+ 'description' => array(
+ 'name' => pht('Description'),
+ 'type' => 'remarkup',
+ 'description' => pht('Short project description.'),
+ ),
+ ));
+ }
+
+}
Index: src/applications/project/customfield/PhabricatorProjectStandardCustomField.php
===================================================================
--- src/applications/project/customfield/PhabricatorProjectStandardCustomField.php
+++ src/applications/project/customfield/PhabricatorProjectStandardCustomField.php
@@ -1,19 +1,11 @@
<?php
-final class PhabricatorProjectConfiguredCustomField
+abstract class PhabricatorProjectStandardCustomField
extends PhabricatorProjectCustomField
implements PhabricatorStandardCustomFieldInterface {
public function getStandardCustomFieldNamespace() {
- return 'project';
- }
-
- public function createFields() {
- return PhabricatorStandardCustomField::buildStandardFields(
- $this,
- PhabricatorEnv::getEnvConfig(
- 'projects.custom-field-definitions',
- array()));
+ return 'project:internal';
}
public function newStorageObject() {

File Metadata

Mime Type
text/plain
Expires
May 11 2024, 7:39 AM (5 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6282062
Default Alt Text
D8182.diff (11 KB)

Event Timeline