@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Remove the "willApplyTransactions()" hook from ApplicationTransactionEditor

Summary:
Depends on D19908. Ref T13222. In D19897, I reordered some transaction code and affected the call order of `willApplyTransactions()`.

It turns out that we use this call for only one thing, and that thing is pretty silly: naming the raw paste data file when editing paste content.

This is only user-visible in the URL when you click "View Raw Paste" and seems exceptionally low-value, so remove the hook and pick a consistent name for the paste datafiles. (We could retain the name behavior in other ways, but it hardly seems worthwhile.)

Test Plan:
- Created and edited a paste.
- Grepped for `willApplyTransactions()`.

Note that `EditEngine` (vs `ApplicationTransacitonEditor`) still has a `willApplyTransactions()`, which has one callsite in Phabricator (in Calendar) and a couple in Instances. That's untouched and still works.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13222

Differential Revision: https://secure.phabricator.com/D19909

+3 -49
+3 -25
src/applications/paste/xaction/PhabricatorPasteContentTransaction.php
··· 5 5 6 6 const TRANSACTIONTYPE = 'paste.create'; 7 7 8 - private $fileName; 9 - 10 8 public function generateOldValue($object) { 11 9 return $object->getFilePHID(); 12 10 } ··· 32 30 return array($error); 33 31 } 34 32 35 - public function willApplyTransactions($object, array $xactions) { 36 - // Find the most user-friendly filename we can by examining the title of 37 - // the paste and the pending transactions. We'll use this if we create a 38 - // new file to store raw content later. 39 - 40 - $name = $object->getTitle(); 41 - if (!strlen($name)) { 42 - $name = 'paste.raw'; 43 - } 44 - 45 - $type_title = PhabricatorPasteTitleTransaction::TRANSACTIONTYPE; 46 - foreach ($xactions as $xaction) { 47 - if ($xaction->getTransactionType() == $type_title) { 48 - $name = $xaction->getNewValue(); 49 - } 50 - } 51 - 52 - $this->fileName = $name; 53 - } 54 - 55 33 public function generateNewValue($object, $value) { 56 34 // If this transaction does not really change the paste content, return 57 35 // the current file PHID so this transaction no-ops. ··· 66 44 $editor = $this->getEditor(); 67 45 $actor = $editor->getActor(); 68 46 69 - $file = $this->newFileForPaste($actor, $this->fileName, $value); 47 + $file = $this->newFileForPaste($actor, $value); 70 48 71 49 return $file->getPHID(); 72 50 } 73 51 74 - private function newFileForPaste(PhabricatorUser $actor, $name, $data) { 52 + private function newFileForPaste(PhabricatorUser $actor, $data) { 75 53 return PhabricatorFile::newFromFileData( 76 54 $data, 77 55 array( 78 - 'name' => $name, 56 + 'name' => 'raw.txt', 79 57 'mime-type' => 'text/plain; charset=utf-8', 80 58 'authorPHID' => $actor->getPHID(), 81 59 'viewPolicy' => PhabricatorPolicies::POLICY_NOONE,
-15
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
··· 1026 1026 $xactions = $this->filterTransactions($object, $xactions); 1027 1027 1028 1028 if (!$is_preview) { 1029 - $this->willApplyTransactions($object, $xactions); 1030 - 1031 1029 $this->hasRequiredMFA = true; 1032 1030 if ($this->getShouldRequireMFA()) { 1033 1031 $this->requireMFA($object, $xactions); ··· 4372 4370 private function getModularTransactionType($type) { 4373 4371 $types = $this->getModularTransactionTypes(); 4374 4372 return idx($types, $type); 4375 - } 4376 - 4377 - private function willApplyTransactions($object, array $xactions) { 4378 - foreach ($xactions as $xaction) { 4379 - $type = $xaction->getTransactionType(); 4380 - 4381 - $xtype = $this->getModularTransactionType($type); 4382 - if (!$xtype) { 4383 - continue; 4384 - } 4385 - 4386 - $xtype->willApplyTransactions($object, $xactions); 4387 - } 4388 4373 } 4389 4374 4390 4375 public function getCreateObjectTitle($author, $object) {
-5
src/applications/transactions/storage/PhabricatorModularTransaction.php
··· 69 69 ->generateNewValue($object, $this->getNewValue()); 70 70 } 71 71 72 - final public function willApplyTransactions($object, array $xactions) { 73 - return $this->getTransactionImplementation() 74 - ->willApplyTransactions($object, $xactions); 75 - } 76 - 77 72 final public function applyInternalEffects($object) { 78 73 return $this->getTransactionImplementation() 79 74 ->applyInternalEffects($object);
-4
src/applications/transactions/storage/PhabricatorModularTransactionType.php
··· 23 23 return array(); 24 24 } 25 25 26 - public function willApplyTransactions($object, array $xactions) { 27 - return; 28 - } 29 - 30 26 public function applyInternalEffects($object, $value) { 31 27 return; 32 28 }