Skip to content

Commit 587faa6

Browse files
author
epriestley
committed
Remove some defunct old-style transaction policy checks
Summary: Ref PHI193. This method of enforcing policy checks is now (mostly) obsolete, and they're generally checked at the Controller/API level instead. Notably, this method does not call `adjustObjectForPolicyChecks(...)` properly, so it can not handle special cases like "creating a project and taking its newly created members into account" for object policies like "Project Members". Just remove these checks, which are redundant with checks elsewhere. Test Plan: - Set Project application default edit policy to "Administrators and Project Members". - Tried to create a project as a non-administrator, adding myself. - Before patch: policy fatal on a VOID object (the project with no PHID generated yet). - After patch: object created properly. Got a sensible policy error if I didn't include myself as a member. - Also verified that other edit rules are still enforced/respected (I can't edit stuff I shouldn't be able to edit). - There's at least a bit of unit test coverage of this, too, which I updated to work via API (which hits the new broad capability checks) instead of via low-level transactions (which enforce only a subset of policy operations now). Reviewers: amckinley Reviewed By: amckinley Differential Revision: https://secure.phabricator.com/D18763
1 parent cc865e5 commit 587faa6

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

src/applications/project/__tests__/PhabricatorProjectCoreTestCase.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,7 @@ public function testEditProject() {
146146
$user = $this->createUser();
147147
$user->save();
148148

149-
$user2 = $this->createUser();
150-
$user2->save();
149+
$user->setAllowInlineCacheGeneration(true);
151150

152151
$proj = $this->createProject($user);
153152

@@ -1289,12 +1288,19 @@ private function attemptProjectEdit(
12891288

12901289
$new_name = $proj->getName().' '.mt_rand();
12911290

1292-
$xaction = new PhabricatorProjectTransaction();
1293-
$xaction->setTransactionType(
1294-
PhabricatorProjectNameTransaction::TRANSACTIONTYPE);
1295-
$xaction->setNewValue($new_name);
1291+
$params = array(
1292+
'objectIdentifier' => $proj->getID(),
1293+
'transactions' => array(
1294+
array(
1295+
'type' => 'name',
1296+
'value' => $new_name,
1297+
),
1298+
),
1299+
);
12961300

1297-
$this->applyTransactions($proj, $user, array($xaction));
1301+
id(new ConduitCall('project.edit', $params))
1302+
->setUser($user)
1303+
->execute();
12981304

12991305
return true;
13001306
}

src/applications/project/editor/PhabricatorProjectTransactionEditor.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,6 @@ protected function requireCapabilities(
120120
PhabricatorApplicationTransaction $xaction) {
121121

122122
switch ($xaction->getTransactionType()) {
123-
case PhabricatorProjectNameTransaction::TRANSACTIONTYPE:
124-
case PhabricatorProjectStatusTransaction::TRANSACTIONTYPE:
125-
case PhabricatorProjectImageTransaction::TRANSACTIONTYPE:
126-
case PhabricatorProjectIconTransaction::TRANSACTIONTYPE:
127-
case PhabricatorProjectColorTransaction::TRANSACTIONTYPE:
128-
PhabricatorPolicyFilter::requireCapability(
129-
$this->requireActor(),
130-
$object,
131-
PhabricatorPolicyCapability::CAN_EDIT);
132-
return;
133123
case PhabricatorProjectLockTransaction::TRANSACTIONTYPE:
134124
PhabricatorPolicyFilter::requireCapability(
135125
$this->requireActor(),

0 commit comments

Comments
 (0)