1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-09 16:32:39 +01:00

Move Project transaction storage to modern tables

Summary:
Ref T4010. Projects have a weird proto-version of ApplicationTransactions which is very similar but not quite the same.

Move the storage to a modern format, but keep all the other code for now.

Test Plan: Migrated project transactions; edited projects.

Reviewers: btrahan, chad

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T4010

Differential Revision: https://secure.phabricator.com/D7370
This commit is contained in:
epriestley 2013-10-22 13:49:28 -07:00
parent 90b83d7a92
commit 9b89e137cf
15 changed files with 175 additions and 324 deletions

View file

@ -0,0 +1,24 @@
RENAME TABLE {$NAMESPACE}_project.project_transaction
TO {$NAMESPACE}_project.project_legacytransaction;
CREATE TABLE {$NAMESPACE}_project.project_transaction (
id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
phid VARCHAR(64) NOT NULL COLLATE utf8_bin,
authorPHID VARCHAR(64) NOT NULL COLLATE utf8_bin,
objectPHID VARCHAR(64) NOT NULL COLLATE utf8_bin,
viewPolicy VARCHAR(64) NOT NULL COLLATE utf8_bin,
editPolicy VARCHAR(64) NOT NULL COLLATE utf8_bin,
commentPHID VARCHAR(64) COLLATE utf8_bin,
commentVersion INT UNSIGNED NOT NULL,
transactionType VARCHAR(32) NOT NULL COLLATE utf8_bin,
oldValue LONGTEXT NOT NULL COLLATE utf8_bin,
newValue LONGTEXT NOT NULL COLLATE utf8_bin,
contentSource LONGTEXT NOT NULL COLLATE utf8_bin,
metadata LONGTEXT NOT NULL COLLATE utf8_bin,
dateCreated INT UNSIGNED NOT NULL,
dateModified INT UNSIGNED NOT NULL,
UNIQUE KEY `key_phid` (phid),
KEY `key_object` (objectPHID)
) ENGINE=InnoDB, COLLATE utf8_general_ci;

View file

@ -0,0 +1,92 @@
<?php
$project_table = new PhabricatorProject();
$conn_w = $project_table->establishConnection('w');
$conn_w->openTransaction();
$src_table = 'project_legacytransaction';
$dst_table = 'project_transaction';
echo "Migrating Project transactions to new format...\n";
$content_source = PhabricatorContentSource::newForSource(
PhabricatorContentSource::SOURCE_LEGACY,
array())->serialize();
$rows = new LiskRawMigrationIterator($conn_w, $src_table);
foreach ($rows as $row) {
$id = $row['id'];
$project_id = $row['projectID'];
echo "Migrating transaction #{$id} (Project {$project_id})...\n";
$project_row = queryfx_one(
$conn_w,
'SELECT phid FROM %T WHERE id = %d',
$project_table->getTableName(),
$project_id);
if (!$project_row) {
continue;
}
$project_phid = $project_row['phid'];
$type_map = array(
'name' => PhabricatorProjectTransaction::TYPE_NAME,
'members' => PhabricatorProjectTransaction::TYPE_MEMBERS,
'status' => PhabricatorProjectTransaction::TYPE_STATUS,
'canview' => PhabricatorTransactions::TYPE_VIEW_POLICY,
'canedit' => PhabricatorTransactions::TYPE_EDIT_POLICY,
'canjoin' => PhabricatorTransactions::TYPE_JOIN_POLICY,
);
$new_type = idx($type_map, $row['transactionType']);
if (!$new_type) {
continue;
}
$xaction_phid = PhabricatorPHID::generateNewPHID(
PhabricatorApplicationTransactionPHIDTypeTransaction::TYPECONST,
PhabricatorProjectPHIDTypeProject::TYPECONST);
queryfx(
$conn_w,
'INSERT IGNORE INTO %T
(phid, authorPHID, objectPHID,
viewPolicy, editPolicy, commentPHID, commentVersion, transactionType,
oldValue, newValue, contentSource, metadata,
dateCreated, dateModified)
VALUES
(%s, %s, %s,
%s, %s, %ns, %d, %s,
%s, %s, %s, %s,
%d, %d)',
$dst_table,
// PHID, Author, Object
$xaction_phid,
$row['authorPHID'],
$project_phid,
// View, Edit, Comment, Version, Type
'public',
$row['authorPHID'],
null,
0,
$new_type,
// Old, New, Source, Meta,
$row['oldValue'],
$row['newValue'],
$content_source,
'{}',
// Created, Modified
$row['dateCreated'],
$row['dateModified']);
}
$conn_w->saveTransaction();
echo "Done.\n";

View file

@ -1205,7 +1205,6 @@ phutil_register_library_map(array(
'PhabricatorFeedStoryManiphestAggregate' => 'applications/feed/story/PhabricatorFeedStoryManiphestAggregate.php',
'PhabricatorFeedStoryNotification' => 'applications/notification/storage/PhabricatorFeedStoryNotification.php',
'PhabricatorFeedStoryPhriction' => 'applications/feed/story/PhabricatorFeedStoryPhriction.php',
'PhabricatorFeedStoryProject' => 'applications/feed/story/PhabricatorFeedStoryProject.php',
'PhabricatorFeedStoryPublisher' => 'applications/feed/PhabricatorFeedStoryPublisher.php',
'PhabricatorFeedStoryReference' => 'applications/feed/storage/PhabricatorFeedStoryReference.php',
'PhabricatorFeedStoryStatus' => 'applications/feed/story/PhabricatorFeedStoryStatus.php',
@ -1542,7 +1541,6 @@ phutil_register_library_map(array(
'PhabricatorProjectStatus' => 'applications/project/constants/PhabricatorProjectStatus.php',
'PhabricatorProjectTestDataGenerator' => 'applications/project/lipsum/PhabricatorProjectTestDataGenerator.php',
'PhabricatorProjectTransaction' => 'applications/project/storage/PhabricatorProjectTransaction.php',
'PhabricatorProjectTransactionType' => 'applications/project/constants/PhabricatorProjectTransactionType.php',
'PhabricatorProjectUpdateController' => 'applications/project/controller/PhabricatorProjectUpdateController.php',
'PhabricatorQuery' => 'infrastructure/query/PhabricatorQuery.php',
'PhabricatorRecaptchaConfigOptions' => 'applications/config/option/PhabricatorRecaptchaConfigOptions.php',
@ -3401,7 +3399,6 @@ phutil_register_library_map(array(
'PhabricatorFeedStoryManiphestAggregate' => 'PhabricatorFeedStoryAggregate',
'PhabricatorFeedStoryNotification' => 'PhabricatorFeedDAO',
'PhabricatorFeedStoryPhriction' => 'PhabricatorFeedStory',
'PhabricatorFeedStoryProject' => 'PhabricatorFeedStory',
'PhabricatorFeedStoryReference' => 'PhabricatorFeedDAO',
'PhabricatorFeedStoryStatus' => 'PhabricatorFeedStory',
'PhabricatorFeedStoryTypeConstants' => 'PhabricatorFeedConstants',
@ -3772,8 +3769,7 @@ phutil_register_library_map(array(
'PhabricatorProjectSearchEngine' => 'PhabricatorApplicationSearchEngine',
'PhabricatorProjectSearchIndexer' => 'PhabricatorSearchDocumentIndexer',
'PhabricatorProjectTestDataGenerator' => 'PhabricatorTestDataGenerator',
'PhabricatorProjectTransaction' => 'PhabricatorProjectDAO',
'PhabricatorProjectTransactionType' => 'PhabricatorProjectConstants',
'PhabricatorProjectTransaction' => 'PhabricatorApplicationTransaction',
'PhabricatorProjectUpdateController' => 'PhabricatorProjectController',
'PhabricatorRecaptchaConfigOptions' => 'PhabricatorApplicationConfigOptions',
'PhabricatorRedirectController' => 'PhabricatorController',

View file

@ -3,11 +3,7 @@
final class PhabricatorFeedStoryTypeConstants
extends PhabricatorFeedConstants {
const STORY_STATUS = 'PhabricatorFeedStoryStatus';
const STORY_DIFFERENTIAL = 'PhabricatorFeedStoryDifferential';
const STORY_PHRICTION = 'PhabricatorFeedStoryPhriction';
const STORY_MANIPHEST = 'PhabricatorFeedStoryManiphest';
const STORY_PROJECT = 'PhabricatorFeedStoryProject';
const STORY_AUDIT = 'PhabricatorFeedStoryAudit';
const STORY_COMMIT = 'PhabricatorFeedStoryCommit';

View file

@ -1,224 +0,0 @@
<?php
final class PhabricatorFeedStoryProject extends PhabricatorFeedStory {
public function getPrimaryObjectPHID() {
return $this->getValue('projectPHID');
}
public function getRequiredHandlePHIDs() {
$req_phids = array();
$data = $this->getStoryData();
switch ($data->getValue('type')) {
case PhabricatorProjectTransactionType::TYPE_MEMBERS:
$old = $data->getValue('old');
$new = $data->getValue('new');
$add = array_diff($new, $old);
$rem = array_diff($old, $new);
$req_phids = array_merge($add, $rem);
break;
}
return array_merge($req_phids, parent::getRequiredHandlePHIDs());
}
public function renderView() {
$data = $this->getStoryData();
$view = $this->newStoryView();
$view->setAppIcon('projects-dark');
$type = $data->getValue('type');
$old = $data->getValue('old');
$new = $data->getValue('new');
$proj_phid = $data->getValue('projectPHID');
$author_phid = $data->getAuthorPHID();
$author_link = $this->linkTo($author_phid);
switch ($type) {
case PhabricatorProjectTransactionType::TYPE_NAME:
if (strlen($old)) {
$action = pht(
'%s renamed project %s from %s to %s.',
$author_link,
$this->linkTo($proj_phid),
$this->renderString($old),
$this->renderString($new));
} else {
$action = pht(
'%s created project %s (as %s).',
$author_link,
$this->linkTo($proj_phid),
$this->renderString($new));
}
break;
case PhabricatorProjectTransactionType::TYPE_STATUS:
$old_name = PhabricatorProjectStatus::getNameForStatus($old);
$new_name = PhabricatorProjectStatus::getNameForStatus($new);
$action = pht(
'%s changed project %s status from %s to %s.',
$author_link,
$this->linkTo($proj_phid),
$this->renderString($old_name),
$this->renderString($new_name));
break;
case PhabricatorProjectTransactionType::TYPE_MEMBERS:
$add = array_diff($new, $old);
$rem = array_diff($old, $new);
if ((count($add) == 1) && (count($rem) == 0) &&
(head($add) == $author_phid)) {
$action = pht(
'%s joined project %s.',
$author_link,
$this->linkTo($proj_phid));
} else if ((count($add) == 0) && (count($rem) == 1) &&
(head($rem) == $author_phid)) {
$action = pht(
'%s left project %s.',
$author_link,
$this->linkTo($proj_phid));
} else if (empty($rem)) {
$action = pht(
'%s added members to project %s: %s.',
$author_link,
$this->linkTo($proj_phid),
$this->renderHandleList($add));
} else if (empty($add)) {
$action = pht(
'%s removed members from project %s: %s.',
$author_link,
$this->linkTo($proj_phid),
$this->renderHandleList($rem));
} else {
$action = pht(
'%s changed members of project %s, added: %s; removed: %s.',
$author_link,
$this->linkTo($proj_phid),
$this->renderHandleList($add),
$this->renderHandleList($rem));
}
break;
case PhabricatorProjectTransactionType::TYPE_CAN_VIEW:
$action = pht(
'%s changed the visibility for %s.',
$author_link,
$this->linkTo($proj_phid));
break;
case PhabricatorProjectTransactionType::TYPE_CAN_EDIT:
$action = pht(
'%s changed the edit policy for %s.',
$author_link,
$this->linkTo($proj_phid));
break;
case PhabricatorProjectTransactionType::TYPE_CAN_JOIN:
$action = pht(
'%s changed the join policy for %s.',
$author_link,
$this->linkTo($proj_phid));
break;
default:
$action = pht(
'%s updated project %s.',
$author_link,
$this->linkTo($proj_phid));
break;
}
$view->setTitle($action);
$view->setImage($this->getHandle($author_phid)->getImageURI());
return $view;
}
public function renderText() {
$type = $this->getValue('type');
$old = $this->getValue('old');
$new = $this->getValue('new');
$proj_handle = $this->getHandle($this->getPrimaryObjectPHID());
$proj_name = $proj_handle->getLinkName();
$proj_uri = PhabricatorEnv::getURI($proj_handle->getURI());
$author_phid = $this->getAuthorPHID();
$author_name = $this->linkTo($author_phid);
switch ($type) {
case PhabricatorProjectTransactionType::TYPE_NAME:
if (strlen($old)) {
$text =
pht('%s renamed project %s from %s to %s %s',
$author_name,
$proj_name,
$old,
$new,
$proj_uri);
} else {
$text =
pht('%s created project %s (as %s) %s',
$author_name,
$proj_name,
$new,
$proj_uri);
}
break;
case PhabricatorProjectTransactionType::TYPE_STATUS:
$text =
pht('%s changed project %s status from %s to %s %s',
$author_name,
$proj_name,
$old,
$new,
$proj_uri);
break;
case PhabricatorProjectTransactionType::TYPE_MEMBERS:
$add = array_diff($new, $old);
$rem = array_diff($old, $new);
if ((count($add) == 1) && (count($rem) == 0) &&
(head($add) == $author_phid)) {
$text =
pht('%s joined project %s %s',
$author_name,
$proj_name,
$proj_uri);
} else if ((count($add) == 0) && (count($rem) == 1) &&
(head($rem) == $author_phid)) {
$text =
pht('%s left project %s %s',
$author_name,
$proj_name,
$proj_uri);
} else if (empty($rem)) {
$text =
pht('%s added members to project %s %s',
$author_name,
$proj_name,
$proj_uri);
} else if (empty($add)) {
$text =
pht('%s removed members from project %s %s',
$author_name,
$proj_name,
$proj_uri);
} else {
$text =
pht('%s changed members of project %s %s',
$author_name,
$proj_name,
$proj_uri);
}
break;
default:
$text =
pht('%s updated project %s %s',
$author_name,
$proj_name,
$proj_uri);
break;
}
return $text;
}
}

View file

@ -1,13 +0,0 @@
<?php
final class PhabricatorProjectTransactionType
extends PhabricatorProjectConstants {
const TYPE_NAME = 'name';
const TYPE_MEMBERS = 'members';
const TYPE_STATUS = 'status';
const TYPE_CAN_VIEW = 'canview';
const TYPE_CAN_EDIT = 'canedit';
const TYPE_CAN_JOIN = 'canjoin';
}

View file

@ -26,13 +26,13 @@ final class PhabricatorProjectCreateController
$xaction = new PhabricatorProjectTransaction();
$xaction->setTransactionType(
PhabricatorProjectTransactionType::TYPE_NAME);
PhabricatorProjectTransaction::TYPE_NAME);
$xaction->setNewValue($request->getStr('name'));
$xactions[] = $xaction;
$xaction = new PhabricatorProjectTransaction();
$xaction->setTransactionType(
PhabricatorProjectTransactionType::TYPE_MEMBERS);
PhabricatorProjectTransaction::TYPE_MEMBERS);
$xaction->setNewValue(array($user->getPHID()));
$xactions[] = $xaction;

View file

@ -54,7 +54,7 @@ final class PhabricatorProjectMembersEditController
if ($changed_something) {
$xaction = new PhabricatorProjectTransaction();
$xaction->setTransactionType(
PhabricatorProjectTransactionType::TYPE_MEMBERS);
PhabricatorProjectTransaction::TYPE_MEMBERS);
$xaction->setNewValue(array_keys($member_map));
$xactions[] = $xaction;
}

View file

@ -39,31 +39,31 @@ final class PhabricatorProjectProfileEditController
$xactions = array();
$xaction = new PhabricatorProjectTransaction();
$xaction->setTransactionType(
PhabricatorProjectTransactionType::TYPE_NAME);
PhabricatorProjectTransaction::TYPE_NAME);
$xaction->setNewValue($request->getStr('name'));
$xactions[] = $xaction;
$xaction = new PhabricatorProjectTransaction();
$xaction->setTransactionType(
PhabricatorProjectTransactionType::TYPE_STATUS);
PhabricatorProjectTransaction::TYPE_STATUS);
$xaction->setNewValue($request->getStr('status'));
$xactions[] = $xaction;
$xaction = new PhabricatorProjectTransaction();
$xaction->setTransactionType(
PhabricatorProjectTransactionType::TYPE_CAN_VIEW);
PhabricatorTransactions::TYPE_VIEW_POLICY);
$xaction->setNewValue($request->getStr('can_view'));
$xactions[] = $xaction;
$xaction = new PhabricatorProjectTransaction();
$xaction->setTransactionType(
PhabricatorProjectTransactionType::TYPE_CAN_EDIT);
PhabricatorTransactions::TYPE_EDIT_POLICY);
$xaction->setNewValue($request->getStr('can_edit'));
$xactions[] = $xaction;
$xaction = new PhabricatorProjectTransaction();
$xaction->setTransactionType(
PhabricatorProjectTransactionType::TYPE_CAN_JOIN);
PhabricatorTransactions::TYPE_JOIN_POLICY);
$xaction->setNewValue($request->getStr('can_join'));
$xactions[] = $xaction;

View file

@ -28,7 +28,7 @@ final class PhabricatorProjectEditor extends PhabricatorEditor {
self::applyOneTransaction(
$project,
$user,
PhabricatorProjectTransactionType::TYPE_MEMBERS,
PhabricatorProjectTransaction::TYPE_MEMBERS,
$members);
}
@ -43,7 +43,7 @@ final class PhabricatorProjectEditor extends PhabricatorEditor {
self::applyOneTransaction(
$project,
$user,
PhabricatorProjectTransactionType::TYPE_MEMBERS,
PhabricatorProjectTransaction::TYPE_MEMBERS,
$members);
}
@ -149,15 +149,16 @@ final class PhabricatorProjectEditor extends PhabricatorEditor {
foreach ($transactions as $xaction) {
$xaction->setAuthorPHID($actor->getPHID());
$xaction->setProjectID($project->getID());
$xaction->setObjectPHID($project->getPHID());
$xaction->setViewPolicy('public');
$xaction->setEditPolicy($actor->getPHID());
$xaction->setContentSource(
PhabricatorContentSource::newForSource(
PhabricatorContentSource::SOURCE_LEGACY,
array()));
$xaction->save();
}
$project->saveTransaction();
foreach ($transactions as $xaction) {
$this->publishTransactionStory($project, $xaction);
}
} catch (AphrontQueryDuplicateKeyException $ex) {
// We already validated the slug, but might race. Try again to see if
// that's the issue. If it is, we'll throw a more specific exception. If
@ -206,13 +207,13 @@ final class PhabricatorProjectEditor extends PhabricatorEditor {
$type = $xaction->getTransactionType();
switch ($type) {
case PhabricatorProjectTransactionType::TYPE_NAME:
case PhabricatorProjectTransaction::TYPE_NAME:
$xaction->setOldValue($project->getName());
break;
case PhabricatorProjectTransactionType::TYPE_STATUS:
case PhabricatorProjectTransaction::TYPE_STATUS:
$xaction->setOldValue($project->getStatus());
break;
case PhabricatorProjectTransactionType::TYPE_MEMBERS:
case PhabricatorProjectTransaction::TYPE_MEMBERS:
$member_phids = $project->getMemberPHIDs();
$old_value = array_values($member_phids);
@ -224,13 +225,13 @@ final class PhabricatorProjectEditor extends PhabricatorEditor {
$new_value = array_values($new_value);
$xaction->setNewValue($new_value);
break;
case PhabricatorProjectTransactionType::TYPE_CAN_VIEW:
case PhabricatorTransactions::TYPE_VIEW_POLICY:
$xaction->setOldValue($project->getViewPolicy());
break;
case PhabricatorProjectTransactionType::TYPE_CAN_EDIT:
case PhabricatorTransactions::TYPE_EDIT_POLICY:
$xaction->setOldValue($project->getEditPolicy());
break;
case PhabricatorProjectTransactionType::TYPE_CAN_JOIN:
case PhabricatorTransactions::TYPE_JOIN_POLICY:
$xaction->setOldValue($project->getJoinPolicy());
break;
default:
@ -245,7 +246,7 @@ final class PhabricatorProjectEditor extends PhabricatorEditor {
$type = $xaction->getTransactionType();
switch ($type) {
case PhabricatorProjectTransactionType::TYPE_NAME:
case PhabricatorProjectTransaction::TYPE_NAME:
$old_slug = $project->getFullPhrictionSlug();
$project->setName($xaction->getNewValue());
$project->setPhrictionSlug($xaction->getNewValue());
@ -279,10 +280,10 @@ final class PhabricatorProjectEditor extends PhabricatorEditor {
}
$this->validateName($project);
break;
case PhabricatorProjectTransactionType::TYPE_STATUS:
case PhabricatorProjectTransaction::TYPE_STATUS:
$project->setStatus($xaction->getNewValue());
break;
case PhabricatorProjectTransactionType::TYPE_MEMBERS:
case PhabricatorProjectTransaction::TYPE_MEMBERS:
$old = array_fill_keys($xaction->getOldValue(), true);
$new = array_fill_keys($xaction->getNewValue(), true);
$this->addEdges = array_keys(array_diff_key($new, $old));
@ -291,10 +292,10 @@ final class PhabricatorProjectEditor extends PhabricatorEditor {
$this->setShouldArchive(true);
}
break;
case PhabricatorProjectTransactionType::TYPE_CAN_VIEW:
case PhabricatorTransactions::TYPE_VIEW_POLICY:
$project->setViewPolicy($xaction->getNewValue());
break;
case PhabricatorProjectTransactionType::TYPE_CAN_EDIT:
case PhabricatorTransactions::TYPE_EDIT_POLICY:
$project->setEditPolicy($xaction->getNewValue());
// You can't edit away your ability to edit the project.
@ -303,7 +304,7 @@ final class PhabricatorProjectEditor extends PhabricatorEditor {
$project,
PhabricatorPolicyCapability::CAN_EDIT);
break;
case PhabricatorProjectTransactionType::TYPE_CAN_JOIN:
case PhabricatorTransactions::TYPE_JOIN_POLICY:
$project->setJoinPolicy($xaction->getNewValue());
break;
default:
@ -311,31 +312,6 @@ final class PhabricatorProjectEditor extends PhabricatorEditor {
}
}
private function publishTransactionStory(
PhabricatorProject $project,
PhabricatorProjectTransaction $xaction) {
$related_phids = array(
$project->getPHID(),
$xaction->getAuthorPHID(),
);
id(new PhabricatorFeedStoryPublisher())
->setStoryType(PhabricatorFeedStoryTypeConstants::STORY_PROJECT)
->setStoryData(
array(
'projectPHID' => $project->getPHID(),
'transactionID' => $xaction->getID(),
'type' => $xaction->getTransactionType(),
'old' => $xaction->getOldValue(),
'new' => $xaction->getNewValue(),
))
->setStoryTime(time())
->setStoryAuthorPHID($xaction->getAuthorPHID())
->setRelatedPHIDs($related_phids)
->publish();
}
private function transactionHasEffect(
PhabricatorProjectTransaction $xaction) {
return ($xaction->getOldValue() !== $xaction->getNewValue());
@ -375,12 +351,12 @@ final class PhabricatorProjectEditor extends PhabricatorEditor {
PhabricatorProjectTransaction $xaction) {
$type = $xaction->getTransactionType();
if ($type != PhabricatorProjectTransactionType::TYPE_MEMBERS) {
if ($type != PhabricatorProjectTransaction::TYPE_MEMBERS) {
return null;
}
switch ($type) {
case PhabricatorProjectTransactionType::TYPE_MEMBERS:
case PhabricatorProjectTransaction::TYPE_MEMBERS:
$old = $xaction->getOldValue();
$new = $xaction->getNewValue();

View file

@ -94,7 +94,7 @@ final class PhabricatorProjectEditorTestCase extends PhabricatorTestCase {
$new_name = $proj->getName().' '.mt_rand();
$xaction = new PhabricatorProjectTransaction();
$xaction->setTransactionType(PhabricatorProjectTransactionType::TYPE_NAME);
$xaction->setTransactionType(PhabricatorProjectTransaction::TYPE_NAME);
$xaction->setNewValue($new_name);
$editor = new PhabricatorProjectEditor($proj);

View file

@ -14,22 +14,22 @@ final class PhabricatorProjectTestDataGenerator
->setAuthorPHID($authorPHID);
$this->addTransaction(
PhabricatorProjectTransactionType::TYPE_NAME,
PhabricatorProjectTransaction::TYPE_NAME,
$title);
$this->addTransaction(
PhabricatorProjectTransactionType::TYPE_MEMBERS,
PhabricatorProjectTransaction::TYPE_MEMBERS,
$this->loadMembersWithAuthor($authorPHID));
$this->addTransaction(
PhabricatorProjectTransactionType::TYPE_STATUS,
PhabricatorProjectTransaction::TYPE_STATUS,
$this->generateProjectStatus());
$this->addTransaction(
PhabricatorProjectTransactionType::TYPE_CAN_VIEW,
PhabricatorTransactions::TYPE_VIEW_POLICY,
PhabricatorPolicies::POLICY_PUBLIC);
$this->addTransaction(
PhabricatorProjectTransactionType::TYPE_CAN_EDIT,
PhabricatorTransactions::TYPE_EDIT_POLICY,
PhabricatorPolicies::POLICY_PUBLIC);
$this->addTransaction(
PhabricatorProjectTransactionType::TYPE_CAN_JOIN,
PhabricatorTransactions::TYPE_JOIN_POLICY,
PhabricatorPolicies::POLICY_PUBLIC);
$editor = id(new PhabricatorProjectEditor($project))

View file

@ -1,23 +1,18 @@
<?php
/**
* @group project
*/
final class PhabricatorProjectTransaction extends PhabricatorProjectDAO {
final class PhabricatorProjectTransaction
extends PhabricatorApplicationTransaction {
protected $projectID;
protected $authorPHID;
protected $transactionType;
protected $oldValue;
protected $newValue;
const TYPE_NAME = 'project:name';
const TYPE_MEMBERS = 'project:members';
const TYPE_STATUS = 'project:status';
public function getConfiguration() {
return array(
self::CONFIG_SERIALIZATION => array(
'oldValue' => self::SERIALIZATION_JSON,
'newValue' => self::SERIALIZATION_JSON,
),
) + parent::getConfiguration();
public function getApplicationName() {
return 'project';
}
public function getApplicationTransactionType() {
return PhabricatorProjectPHIDTypeProject::TYPECONST;
}
}

View file

@ -6,6 +6,7 @@ final class PhabricatorTransactions {
const TYPE_SUBSCRIBERS = 'core:subscribers';
const TYPE_VIEW_POLICY = 'core:view-policy';
const TYPE_EDIT_POLICY = 'core:edit-policy';
const TYPE_JOIN_POLICY = 'core:join-policy';
const TYPE_EDGE = 'core:edge';
const TYPE_CUSTOMFIELD = 'core:customfield';

View file

@ -1692,6 +1692,14 @@ final class PhabricatorBuiltinPatchList extends PhabricatorSQLPatchList {
'type' => 'sql',
'name' => $this->getPatchPath('20131020.col1.sql'),
),
'20131020.pxaction.sql' => array(
'type' => 'sql',
'name' => $this->getPatchPath('20131020.pxaction.sql'),
),
'20131020.pxactionmig.php' => array(
'type' => 'php',
'name' => $this->getPatchPath('20131020.pxactionmig.php'),
),
);
}
}