@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

Disable caching of remarkup previews

Summary:
We currently cache previews, but the vast majority of previews are never rendered again (e.g., they're a preview of someone partway through typing a comment).

Especially when editing large documents (Legalpad, Phriction), this can bloat the markup cache with data that will never be read and won't get purged for 30 days.

In particular, most of the data on `admin.phacility.com` is currently 1,000 previews of legalpad documents as I made minor edits to them over the course of several hours.

This isn't a big concern, but it's a very easy fix.

Test Plan:
- Previewed a legalpad document, verified that cache rows were not written as I mashed the keyboard.
- Saved the document, verified a new cache row was written.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

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

+15
+14
src/infrastructure/markup/PhabricatorMarkupOneOff.php
··· 17 17 private $content; 18 18 private $preserveLinebreaks; 19 19 private $engineRuleset; 20 + private $disableCache; 20 21 21 22 public function setEngineRuleset($engine_ruleset) { 22 23 $this->engineRuleset = $engine_ruleset; ··· 41 42 return $this->content; 42 43 } 43 44 45 + public function setDisableCache($disable_cache) { 46 + $this->disableCache = $disable_cache; 47 + return $this; 48 + } 49 + 50 + public function getDisableCache() { 51 + return $this->disableCache; 52 + } 53 + 44 54 public function getMarkupFieldKey($field) { 45 55 return PhabricatorHash::digestForIndex($this->getContent()).':oneoff'; 46 56 } ··· 74 84 } 75 85 76 86 public function shouldUseMarkupCache($field) { 87 + if ($this->getDisableCache()) { 88 + return false; 89 + } 90 + 77 91 return true; 78 92 } 79 93
+1
src/infrastructure/markup/PhabricatorMarkupPreviewController.php
··· 12 12 $output = PhabricatorMarkupEngine::renderOneObject( 13 13 id(new PhabricatorMarkupOneOff()) 14 14 ->setPreserveLinebreaks(true) 15 + ->setDisableCache(true) 15 16 ->setContent($text), 16 17 'default', 17 18 $viewer);