Use modern two-stage markup cache (PhabricatorMarkupInterface) in Differential

Summary:
See T1963 for discussion of the Facebook-specific hack.

Differential currently uses a one-stage cache (render -> postprocess -> save in cache) rather than the two-stage cache (render -> save in cache -> postprocess) offered by `PhabricatorMarkupInteface`. This breaks Differential comments coming out of cache for the lightbox, and makes various other things suboptimal (status of handles like @mentions and embeds are not displayed accurately).

Instead, use the modern stuff.

Test Plan:
  - Created preview comments and inlines in Differential.
  - Edited a Differential inline.
  - Submitted main and inline Differential comments.
  - Viewed and edited Differential summary and test plan.
  - Created preview comments and inlines in Diffusion.
  - Submitted comments and inlines in Diffusion.
  - Verified Differential now loads and saves to the generalized markup cache (Diffusion is close, but main comments still hold a single-stage cache).
  - Verified old Differential comments work correctly with the lightbox.

Reviewers: vrana, btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T1963

Differential Revision: https://secure.phabricator.com/D3804
This commit is contained in:
epriestley
2012-10-23 17:33:58 -07:00
parent d984a3ffa4
commit fdf90b46eb
13 changed files with 178 additions and 42 deletions

View File

@@ -222,7 +222,12 @@ abstract class PhabricatorInlineCommentController
$request = $this->getRequest();
$user = $request->getUser();
$engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine();
$engine = new PhabricatorMarkupEngine();
$engine->setViewer($user);
$engine->addObject(
$inline,
PhabricatorInlineCommentInterface::MARKUP_FIELD_BODY);
$engine->process();
$phids = array($user->getPHID());

View File

@@ -27,7 +27,15 @@ abstract class PhabricatorInlineCommentPreviewController
$inlines = $this->loadInlineComments();
assert_instances_of($inlines, 'PhabricatorInlineCommentInterface');
$engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine();
$engine = new PhabricatorMarkupEngine();
$engine->setViewer($user);
foreach ($inlines as $inline) {
$engine->addObject(
$inline,
PhabricatorInlineCommentInterface::MARKUP_FIELD_BODY);
}
$engine->process();
$phids = array($user->getPHID());
$handles = $this->loadViewerHandles($phids);

View File

@@ -19,7 +19,9 @@
/**
* Shared interface used by Differential and Diffusion inline comments.
*/
interface PhabricatorInlineCommentInterface {
interface PhabricatorInlineCommentInterface extends PhabricatorMarkupInterface {
const MARKUP_FIELD_BODY = 'markup:body';
public function setChangesetID($id);
public function getChangesetID();