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

Implement PhabricatorMarkupInterface in Diffusion/Audit comments

Summary: Followup to D3804. Makes Diffusion main comments (not just inlines) render properly with the modern markup pipeline.

Test Plan: Created previews and inline previews. Edited inlines. Saved comment, viewed comment. Verified caches were read and written using "Services" tab.

Reviewers: btrahan, vrana

Reviewed By: vrana

CC: aran

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

+83 -37
+8
src/applications/audit/controller/PhabricatorAuditPreviewController.php
··· 61 61 $phids = array_merge($phids, $ccs); 62 62 } 63 63 64 + $engine = new PhabricatorMarkupEngine(); 65 + $engine->setViewer($user); 66 + $engine->addObject( 67 + $comment, 68 + PhabricatorAuditComment::MARKUP_FIELD_BODY); 69 + $engine->process(); 70 + 64 71 $view = id(new DiffusionCommentView()) 72 + ->setMarkupEngine($engine) 65 73 ->setUser($user) 66 74 ->setComment($comment) 67 75 ->setIsPreview(true);
+28 -1
src/applications/audit/storage/PhabricatorAuditComment.php
··· 16 16 * limitations under the License. 17 17 */ 18 18 19 - final class PhabricatorAuditComment extends PhabricatorAuditDAO { 19 + final class PhabricatorAuditComment extends PhabricatorAuditDAO 20 + implements PhabricatorMarkupInterface { 20 21 21 22 const METADATA_ADDED_AUDITORS = 'added-auditors'; 22 23 const METADATA_ADDED_CCS = 'added-ccs'; 24 + 25 + const MARKUP_FIELD_BODY = 'markup:body'; 23 26 24 27 protected $phid; 25 28 protected $actorPHID; ··· 39 42 40 43 public function generatePHID() { 41 44 return PhabricatorPHID::generateNewPHID('ACMT'); 45 + } 46 + 47 + 48 + /* -( PhabricatorMarkupInterface Implementation )-------------------------- */ 49 + 50 + 51 + public function getMarkupFieldKey($field) { 52 + return 'AC:'.$this->getID(); 53 + } 54 + 55 + public function newMarkupEngine($field) { 56 + return PhabricatorMarkupEngine::newDiffusionMarkupEngine(); 57 + } 58 + 59 + public function getMarkupText($field) { 60 + return $this->getContent(); 61 + } 62 + 63 + public function didMarkupText($field, $output, PhutilMarkupEngine $engine) { 64 + return $output; 65 + } 66 + 67 + public function shouldUseMarkupCache($field) { 68 + return (bool)$this->getID(); 42 69 } 43 70 44 71 }
+18
src/applications/diffusion/controller/DiffusionCommitController.php
··· 498 498 $path_map = ipull($path_map, 'path', 'id'); 499 499 } 500 500 501 + $engine = new PhabricatorMarkupEngine(); 502 + $engine->setViewer($user); 503 + 504 + foreach ($comments as $comment) { 505 + $engine->addObject( 506 + $comment, 507 + PhabricatorAuditComment::MARKUP_FIELD_BODY); 508 + } 509 + 510 + foreach ($inlines as $inline) { 511 + $engine->addObject( 512 + $inline, 513 + PhabricatorInlineCommentInterface::MARKUP_FIELD_BODY); 514 + } 515 + 516 + $engine->process(); 517 + 501 518 $view = new DiffusionCommentListView(); 519 + $view->setMarkupEngine($engine); 502 520 $view->setUser($user); 503 521 $view->setComments($comments); 504 522 $view->setInlineComments($inlines);
+11
src/applications/diffusion/view/DiffusionCommentListView.php
··· 23 23 private $inlineComments = array(); 24 24 private $pathMap = array(); 25 25 private $handles = array(); 26 + private $markupEngine; 26 27 27 28 public function setUser(PhabricatorUser $user) { 28 29 $this->user = $user; ··· 44 45 public function setPathMap(array $path_map) { 45 46 $this->pathMap = $path_map; 46 47 return $this; 48 + } 49 + 50 + public function setMarkupEngine(PhabricatorMarkupEngine $markup_engine) { 51 + $this->markupEngine = $markup_engine; 52 + return $this; 53 + } 54 + 55 + public function getMarkupEngine() { 56 + return $this->markupEngine; 47 57 } 48 58 49 59 public function getRequiredHandlePHIDs() { ··· 87 97 $inlines = idx($inline_comments, $comment->getID(), array()); 88 98 89 99 $view = id(new DiffusionCommentView()) 100 + ->setMarkupEngine($this->getMarkupEngine()) 90 101 ->setComment($comment) 91 102 ->setInlineComments($inlines) 92 103 ->setCommentNumber($num)
+18 -13
src/applications/diffusion/view/DiffusionCommentView.php
··· 26 26 private $pathMap; 27 27 28 28 private $inlineComments; 29 - 30 - private $engine; 29 + private $markupEngine; 31 30 32 31 public function setUser(PhabricatorUser $user) { 33 32 $this->user = $user; ··· 64 63 public function setPathMap(array $path_map) { 65 64 $this->pathMap = $path_map; 66 65 return $this; 66 + } 67 + 68 + public function setMarkupEngine(PhabricatorMarkupEngine $markup_engine) { 69 + $this->markupEngine = $markup_engine; 70 + return $this; 71 + } 72 + 73 + public function getMarkupEngine() { 74 + return $this->markupEngine; 67 75 } 68 76 69 77 public function getRequiredHandlePHIDs() { ··· 146 154 147 155 private function renderContent() { 148 156 $comment = $this->comment; 149 - $engine = $this->getEngine(); 157 + $engine = $this->getMarkupEngine(); 150 158 151 159 if (!strlen($comment->getContent()) && empty($this->inlineComments)) { 152 160 return null; 153 161 } else { 154 162 return 155 163 '<div class="phabricator-remarkup">'. 156 - $engine->markupText($comment->getContent()). 164 + $engine->getOutput( 165 + $comment, 166 + PhabricatorAuditComment::MARKUP_FIELD_BODY). 157 167 $this->renderSingleView($this->renderInlines()). 158 168 '</div>'; 159 169 } ··· 163 173 if (!$this->inlineComments) { 164 174 return null; 165 175 } 176 + 177 + $engine = $this->getMarkupEngine(); 166 178 167 179 $inlines_by_path = mgroup($this->inlineComments, 'getPathID'); 168 180 ··· 179 191 'id' => $inline->getID(), 180 192 'line' => $inline->getLineNumber(), 181 193 'length' => $inline->getLineLength(), 182 - 'content' => PhabricatorInlineSummaryView::renderCommentContent( 194 + 'content' => $engine->getOutput( 183 195 $inline, 184 - $this->getEngine()), 196 + PhabricatorInlineCommentInterface::MARKUP_FIELD_BODY), 185 197 ); 186 198 } 187 199 ··· 189 201 } 190 202 191 203 return $view; 192 - } 193 - 194 - private function getEngine() { 195 - if (!$this->engine) { 196 - $this->engine = PhabricatorMarkupEngine::newDiffusionMarkupEngine(); 197 - } 198 - return $this->engine; 199 204 } 200 205 201 206 private function renderHandleList(array $phids) {
-23
src/infrastructure/diff/view/PhabricatorInlineSummaryView.php
··· 29 29 return $this; 30 30 } 31 31 32 - public static function renderCommentContent( 33 - PhabricatorInlineCommentInterface $inline, 34 - PhutilMarkupEngine $engine) { 35 - 36 - $inline_content = $inline->getContent(); 37 - if (strlen($inline_content)) { 38 - $inline_cache = $inline->getCache(); 39 - if ($inline_cache) { 40 - $inline_content = $inline_cache; 41 - } else { 42 - $inline_content = $engine->markupText($inline_content); 43 - if ($inline->getID()) { 44 - $inline->setCache($inline_content); 45 - $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); 46 - $inline->save(); 47 - unset($unguarded); 48 - } 49 - } 50 - } 51 - 52 - return $inline_content; 53 - } 54 - 55 32 public function render() { 56 33 require_celerity_resource('inline-comment-summary-css'); 57 34 return $this->renderHeader().$this->renderTable();