From 3d8eb641ea49b8556dcb587e50131a9475846ff5 Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Wed, 14 Aug 2013 17:32:16 -0700 Subject: [PATCH] Conpherence - fix conpherence create Summary: somewhere along the line this broke. Before this patch we fail the visibility check since its based on Conpherence Participants which don't get created and attached until applyExternalEffects. Believe it or not, this was the least gross fix I could come up with; since the permission check is done SO early most other ideas I had involved creating a dummy participant object to pass the check then handling things for real later on... Ref T3723. Test Plan: created a conpherence with myself - great success Reviewers: epriestley Reviewed By: epriestley CC: chad, Korvin, aran Maniphest Tasks: T3723 Differential Revision: https://secure.phabricator.com/D6762 --- .../conpherence/editor/ConpherenceEditor.php | 21 ++++++++++++++++--- .../conpherence/storage/ConpherenceThread.php | 4 ++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/applications/conpherence/editor/ConpherenceEditor.php b/src/applications/conpherence/editor/ConpherenceEditor.php index d45c0e03ec..e3f9924f2f 100644 --- a/src/applications/conpherence/editor/ConpherenceEditor.php +++ b/src/applications/conpherence/editor/ConpherenceEditor.php @@ -45,8 +45,6 @@ final class ConpherenceEditor extends PhabricatorApplicationTransactionEditor { } if (!$errors) { - $conpherence->openTransaction(); - $conpherence->save(); $xactions = array(); $xactions[] = id(new ConpherenceTransaction()) ->setTransactionType(ConpherenceTransactionType::TYPE_PARTICIPANTS) @@ -74,7 +72,6 @@ final class ConpherenceEditor extends PhabricatorApplicationTransactionEditor { ->setActor($creator) ->applyTransactions($conpherence, $xactions); - $conpherence->saveTransaction(); } return array($errors, $conpherence); @@ -172,6 +169,24 @@ final class ConpherenceEditor extends PhabricatorApplicationTransactionEditor { return $lock; } + /** + * We need to apply initial effects IFF the conpherence is new. We must + * save the conpherence first thing to make sure we have an id and a phid. + */ + protected function shouldApplyInitialEffects( + PhabricatorLiskDAO $object, + array $xactions) { + + return !$object->getID(); + } + + protected function applyInitialEffects( + PhabricatorLiskDAO $object, + array $xactions) { + + $object->save(); + } + protected function applyCustomInternalTransaction( PhabricatorLiskDAO $object, PhabricatorApplicationTransaction $xaction) { diff --git a/src/applications/conpherence/storage/ConpherenceThread.php b/src/applications/conpherence/storage/ConpherenceThread.php index b7e13e7db6..607eeea726 100644 --- a/src/applications/conpherence/storage/ConpherenceThread.php +++ b/src/applications/conpherence/storage/ConpherenceThread.php @@ -213,6 +213,10 @@ final class ConpherenceThread extends ConpherenceDAO } public function hasAutomaticCapability($capability, PhabricatorUser $user) { + // this bad boy isn't even created yet so go nuts $user + if (!$this->getID()) { + return true; + } $participants = $this->getParticipants(); return isset($participants[$user->getPHID()]); }