Differential D18398 Diff 44240 src/applications/differential/xaction/DifferentialRevisionReviewersTransaction.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/xaction/DifferentialRevisionReviewersTransaction.php
| Show First 20 Lines • Show All 100 Lines • ▼ Show 20 Lines | public function getTransactionHasEffect($object, $old, $new) { | ||||
| ksort($old); | ksort($old); | ||||
| ksort($new); | ksort($new); | ||||
| return ($old !== $new); | return ($old !== $new); | ||||
| } | } | ||||
| public function applyExternalEffects($object, $value) { | public function applyExternalEffects($object, $value) { | ||||
| $src_phid = $object->getPHID(); | $src_phid = $object->getPHID(); | ||||
| // This is currently double-writing: to the old (edge) store and the new | |||||
| // (reviewer) store. Do the old edge write first. | |||||
| $old = $this->generateOldValue($object); | $old = $this->generateOldValue($object); | ||||
| $new = $value; | $new = $value; | ||||
| $edge_type = DifferentialRevisionHasReviewerEdgeType::EDGECONST; | |||||
| $editor = new PhabricatorEdgeEditor(); | |||||
| $rem = array_diff_key($old, $new); | $rem = array_diff_key($old, $new); | ||||
| foreach ($rem as $dst_phid => $status) { | |||||
| $editor->removeEdge($src_phid, $edge_type, $dst_phid); | |||||
| } | |||||
| foreach ($new as $dst_phid => $status) { | |||||
| $old_status = idx($old, $dst_phid); | |||||
| if ($old_status === $status) { | |||||
| continue; | |||||
| } | |||||
| $data = array( | |||||
| 'data' => array( | |||||
| 'status' => $status, | |||||
| // TODO: This seemes like it's buggy before the Modular Transactions | |||||
| // changes. Figure out what's going on here? We don't have a very | |||||
| // clean way to get the active diff ID right now. | |||||
| 'diffID' => null, | |||||
| ), | |||||
| ); | |||||
| $editor->addEdge($src_phid, $edge_type, $dst_phid, $data); | |||||
| } | |||||
| $editor->save(); | |||||
| // Now, do the new write. | |||||
| $table = new DifferentialReviewer(); | $table = new DifferentialReviewer(); | ||||
| $table_name = $table->getTableName(); | $table_name = $table->getTableName(); | ||||
| $conn = $table->establishConnection('w'); | $conn = $table->establishConnection('w'); | ||||
| if ($rem) { | if ($rem) { | ||||
| queryfx( | queryfx( | ||||
| $conn, | $conn, | ||||
| ▲ Show 20 Lines • Show All 269 Lines • Show Last 20 Lines | |||||