mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-10 14:51:06 +01:00
Adjust paste content transaction to support earlier file PHID extraction
Summary: Ref T13603. New transactional file attachment extracts PHIDs earlier than the older mechanism did. Allow either pathway to save content and extract a PHID. Test Plan: - Created and modified a paste. - Confirmed both pathways do old and new storage writes. Maniphest Tasks: T13603 Differential Revision: https://secure.phabricator.com/D21817
This commit is contained in:
parent
d017f3f210
commit
4a2d961e76
1 changed files with 16 additions and 1 deletions
|
@ -5,6 +5,8 @@ final class PhabricatorPasteContentTransaction
|
||||||
|
|
||||||
const TRANSACTIONTYPE = 'paste.create';
|
const TRANSACTIONTYPE = 'paste.create';
|
||||||
|
|
||||||
|
private $filePHID;
|
||||||
|
|
||||||
public function generateOldValue($object) {
|
public function generateOldValue($object) {
|
||||||
return $object->getFilePHID();
|
return $object->getFilePHID();
|
||||||
}
|
}
|
||||||
|
@ -14,7 +16,8 @@ final class PhabricatorPasteContentTransaction
|
||||||
}
|
}
|
||||||
|
|
||||||
public function extractFilePHIDs($object, $value) {
|
public function extractFilePHIDs($object, $value) {
|
||||||
return array($value);
|
$file_phid = $this->getFilePHID($object, $value);
|
||||||
|
return array($file_phid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validateTransactions($object, array $xactions) {
|
public function validateTransactions($object, array $xactions) {
|
||||||
|
@ -31,6 +34,18 @@ final class PhabricatorPasteContentTransaction
|
||||||
}
|
}
|
||||||
|
|
||||||
public function generateNewValue($object, $value) {
|
public function generateNewValue($object, $value) {
|
||||||
|
return $this->getFilePHID($object, $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getFilePHID($object, $value) {
|
||||||
|
if ($this->filePHID === null) {
|
||||||
|
$this->filePHID = $this->newFilePHID($object, $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->filePHID;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function newFilePHID($object, $value) {
|
||||||
// If this transaction does not really change the paste content, return
|
// If this transaction does not really change the paste content, return
|
||||||
// the current file PHID so this transaction no-ops.
|
// the current file PHID so this transaction no-ops.
|
||||||
$old_content = $object->getRawContent();
|
$old_content = $object->getRawContent();
|
||||||
|
|
Loading…
Reference in a new issue