@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.

Fix an issue with embedding slowvotes

Summary:
In some applications, using `{V2}` syntax to embed a vote throws. The chain of causality looks like this:

- We try to render a `phabricator_form()`.
- This requires a CSRF token.
- We look for a CSRF token on the user.
- It's an omnipotent user with no token, so everything fails.

To resolve this, make sure we always pass the real user in.

Test Plan:
- Lots of `grep`.
- Made a Differential comment with `{V2}`.
- Made a Diffusion comment with `{V2}`.
- Made a Maniphest comment with `{V2}`.
- Replied to a Conpherence thread with `{V2}`.
- Created a Conpherence thread with `{V2}`.
- Used Conduit to update a Conpherence thread with `{V2}`.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley, lkassianik

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

+26 -11
+1
src/applications/audit/editor/PhabricatorAuditCommentEditor.php
··· 76 76 77 77 // Find any "@mentions" in the content blocks. 78 78 $mention_ccs = PhabricatorMarkupEngine::extractPHIDsFromMentions( 79 + $this->getActor(), 79 80 $content_blocks); 80 81 if ($mention_ccs) { 81 82 $metacc = idx(
+4 -1
src/applications/conpherence/conduit/ConduitAPI_conpherence_updatethread_Method.php
··· 90 90 if ($message) { 91 91 $xactions = array_merge( 92 92 $xactions, 93 - $editor->generateTransactionsFromText($conpherence, $message)); 93 + $editor->generateTransactionsFromText( 94 + $user, 95 + $conpherence, 96 + $message)); 94 97 } 95 98 96 99 try {
+1
src/applications/conpherence/controller/ConpherenceUpdateController.php
··· 55 55 case ConpherenceUpdateActions::MESSAGE: 56 56 $message = $request->getStr('text'); 57 57 $xactions = $editor->generateTransactionsFromText( 58 + $user, 58 59 $conpherence, 59 60 $message); 60 61 $delete_draft = true;
+7 -6
src/applications/conpherence/editor/ConpherenceEditor.php
··· 34 34 $errors[] = self::ERROR_EMPTY_MESSAGE; 35 35 } 36 36 37 - $file_phids = 38 - PhabricatorMarkupEngine::extractFilePHIDsFromEmbeddedFiles( 39 - array($message)); 37 + $file_phids = PhabricatorMarkupEngine::extractFilePHIDsFromEmbeddedFiles( 38 + $creator, 39 + array($message)); 40 40 if ($file_phids) { 41 41 $files = id(new PhabricatorFileQuery()) 42 42 ->setViewer($creator) ··· 78 78 } 79 79 80 80 public function generateTransactionsFromText( 81 + PhabricatorUser $viewer, 81 82 ConpherenceThread $conpherence, 82 83 $text) { 83 84 84 85 $files = array(); 85 - $file_phids = 86 - PhabricatorMarkupEngine::extractFilePHIDsFromEmbeddedFiles( 87 - array($text)); 86 + $file_phids = PhabricatorMarkupEngine::extractFilePHIDsFromEmbeddedFiles( 87 + $viewer, 88 + array($text)); 88 89 // Since these are extracted from text, we might be re-including the 89 90 // same file -- e.g. a mock under discussion. Filter files we 90 91 // already have.
+1
src/applications/conpherence/mail/ConpherenceReplyHandler.php
··· 82 82 $xactions = array_merge( 83 83 $xactions, 84 84 $editor->generateTransactionsFromText( 85 + $user, 85 86 $conpherence, 86 87 $body)); 87 88
+1
src/applications/maniphest/controller/ManiphestTransactionSaveController.php
··· 26 26 // list of all the CCs and then construct a transaction for them at the 27 27 // end if necessary. 28 28 $added_ccs = PhabricatorMarkupEngine::extractPHIDsFromMentions( 29 + $user, 29 30 array( 30 31 $request->getStr('comments'), 31 32 ));
+4 -1
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
··· 973 973 } 974 974 975 975 $texts = array_mergev($blocks); 976 - $phids = PhabricatorMarkupEngine::extractPHIDsFromMentions($texts); 976 + $phids = PhabricatorMarkupEngine::extractPHIDsFromMentions( 977 + $this->getActor(), 978 + $texts); 977 979 978 980 $this->mentionedPHIDs = $phids; 979 981 ··· 2173 2175 $phids = array(); 2174 2176 if ($blocks) { 2175 2177 $phids[] = PhabricatorMarkupEngine::extractFilePHIDsFromEmbeddedFiles( 2178 + $this->getActor(), 2176 2179 $blocks); 2177 2180 } 2178 2181
+7 -3
src/infrastructure/markup/PhabricatorMarkupEngine.php
··· 494 494 return $engine; 495 495 } 496 496 497 - public static function extractPHIDsFromMentions(array $content_blocks) { 497 + public static function extractPHIDsFromMentions( 498 + PhabricatorUser $viewer, 499 + array $content_blocks) { 500 + 498 501 $mentions = array(); 499 502 500 503 $engine = self::newDifferentialMarkupEngine(); 501 - $engine->setConfig('viewer', PhabricatorUser::getOmnipotentUser()); 504 + $engine->setConfig('viewer', $viewer); 502 505 503 506 foreach ($content_blocks as $content_block) { 504 507 $engine->markupText($content_block); ··· 512 515 } 513 516 514 517 public static function extractFilePHIDsFromEmbeddedFiles( 518 + PhabricatorUser $viewer, 515 519 array $content_blocks) { 516 520 $files = array(); 517 521 518 522 $engine = self::newDifferentialMarkupEngine(); 519 - $engine->setConfig('viewer', PhabricatorUser::getOmnipotentUser()); 523 + $engine->setConfig('viewer', $viewer); 520 524 521 525 foreach ($content_blocks as $content_block) { 522 526 $engine->markupText($content_block);