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

Pass a real context object to Phriction previews, fixing mentions

Summary:
Fixes T13662. Phriction currently passes a map as a "context object", but this code is ancient and predates the modern meaning of a "context object". In modern code, context objects should be real objects.

Provide a real object as a context object. We do this by either loading the actual document or constructing a synthetic version of it.

Test Plan:
- Edited an existing document, observing the preview:
- Used a mention rule, saw a preview.
- Used `[[ a ]]` and `[[ ./a ]]` absolute and relative reference rules, saw accurate previews.
- Edited a new document, observing the preview:
- Used a mention rule, saw a preview.
- Used absolute/relative references, saw accurate previews.
- Grepped for other references to the removed properties (`phriction.isPreview` and `phriction.slug`), found none remaining.

Reviewers: 0

Reviewed By: 0

Maniphest Tasks: T13662

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

+21 -14
+21 -7
src/applications/phriction/controller/PhrictionMarkupPreviewController.php
··· 3 3 final class PhrictionMarkupPreviewController 4 4 extends PhabricatorController { 5 5 6 - public function processRequest() { 7 - $request = $this->getRequest(); 8 - $viewer = $request->getUser(); 6 + public function handleRequest(AphrontRequest $request) { 7 + $viewer = $request->getViewer(); 9 8 10 9 $text = $request->getStr('text'); 11 10 $slug = $request->getStr('slug'); 12 11 12 + $document = id(new PhrictionDocumentQuery()) 13 + ->setViewer($viewer) 14 + ->withSlugs(array($slug)) 15 + ->needContent(true) 16 + ->executeOne(); 17 + if (!$document) { 18 + $document = PhrictionDocument::initializeNewDocument( 19 + $viewer, 20 + $slug); 21 + 22 + $content = id(new PhrictionContent()) 23 + ->setSlug($slug); 24 + 25 + $document 26 + ->setPHID($document->generatePHID()) 27 + ->attachContent($content); 28 + } 29 + 13 30 $output = PhabricatorMarkupEngine::renderOneObject( 14 31 id(new PhabricatorMarkupOneOff()) 15 32 ->setPreserveLinebreaks(true) ··· 17 34 ->setContent($text), 18 35 'default', 19 36 $viewer, 20 - array( 21 - 'phriction.isPreview' => true, 22 - 'phriction.slug' => $slug, 23 - )); 37 + $document); 24 38 25 39 return id(new AphrontAjaxResponse()) 26 40 ->setContent($output);
-7
src/applications/phriction/markup/PhrictionRemarkupRule.php
··· 273 273 return null; 274 274 } 275 275 276 - // Handle content when it's a preview for the Phriction editor. 277 - if (is_array($context)) { 278 - if (idx($context, 'phriction.isPreview')) { 279 - return idx($context, 'phriction.slug'); 280 - } 281 - } 282 - 283 276 if ($context instanceof PhrictionContent) { 284 277 return $context->getSlug(); 285 278 }