Skip to content

Commit 4a2d961

Browse files
author
epriestley
committedMay 19, 2022
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
1 parent d017f3f commit 4a2d961

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed
 

‎src/applications/paste/xaction/PhabricatorPasteContentTransaction.php

+16-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ final class PhabricatorPasteContentTransaction
55

66
const TRANSACTIONTYPE = 'paste.create';
77

8+
private $filePHID;
9+
810
public function generateOldValue($object) {
911
return $object->getFilePHID();
1012
}
@@ -14,7 +16,8 @@ public function applyInternalEffects($object, $value) {
1416
}
1517

1618
public function extractFilePHIDs($object, $value) {
17-
return array($value);
19+
$file_phid = $this->getFilePHID($object, $value);
20+
return array($file_phid);
1821
}
1922

2023
public function validateTransactions($object, array $xactions) {
@@ -31,6 +34,18 @@ public function validateTransactions($object, array $xactions) {
3134
}
3235

3336
public function generateNewValue($object, $value) {
37+
return $this->getFilePHID($object, $value);
38+
}
39+
40+
private function getFilePHID($object, $value) {
41+
if ($this->filePHID === null) {
42+
$this->filePHID = $this->newFilePHID($object, $value);
43+
}
44+
45+
return $this->filePHID;
46+
}
47+
48+
private function newFilePHID($object, $value) {
3449
// If this transaction does not really change the paste content, return
3550
// the current file PHID so this transaction no-ops.
3651
$old_content = $object->getRawContent();

0 commit comments

Comments
 (0)
Failed to load comments.