public function getValueForTransaction() { $new = parent::getValueForTransaction(); if (!$this->getUseEdgeTransactions()) { return $new; } $old = $this->getInitialValue(); if ($old === null) { return array('=' => array_fuse($new)); } // If we're building an edge transaction and the request has data about the // original value the user saw when they loaded the form, interpret the // edit as a mixture of "+" and "-" operations instead of a single "=" // operation. This limits our exposure to race conditions by making most // concurrent edits merge correctly. $add = array_diff($new, $old); $rem = array_diff($old, $new); $value = array(); if ($add) { $value['+'] = array_fuse($add); } if ($rem) { $value['-'] = array_fuse($rem); } return $value; }
protected function getValueForTransaction() { $new = parent::getValueForTransaction(); $edge_types = array(PhabricatorTransactions::TYPE_EDGE => true, PhabricatorTransactions::TYPE_SUBSCRIBERS => true); if (isset($edge_types[$this->getTransactionType()])) { if ($this->originalValue !== null) { // If we're building an edge transaction and the request has data // about the original value the user saw when they loaded the form, // interpret the edit as a mixture of "+" and "-" operations instead // of a single "=" operation. This limits our exposure to race // conditions by making most concurrent edits merge correctly. $new = parent::getValueForTransaction(); $old = $this->originalValue; $add = array_diff($new, $old); $rem = array_diff($old, $new); $value = array(); if ($add) { $value['+'] = array_fuse($add); } if ($rem) { $value['-'] = array_fuse($rem); } return $value; } else { if (!is_array($new)) { throw new Exception(print_r($new, true)); } return array('=' => array_fuse($new)); } } return $new; }