diff --git a/src/applications/calendar/storage/PhabricatorCalendarEvent.php b/src/applications/calendar/storage/PhabricatorCalendarEvent.php index b2e81b0e8b..e566a77b76 100644 --- a/src/applications/calendar/storage/PhabricatorCalendarEvent.php +++ b/src/applications/calendar/storage/PhabricatorCalendarEvent.php @@ -1182,9 +1182,8 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO * @task markup */ public function getMarkupFieldKey($field) { - $hash = PhabricatorHash::digest($this->getMarkupText($field)); - $id = $this->getID(); - return "calendar:T{$id}:{$field}:{$hash}"; + $content = $this->getMarkupText($field); + return PhabricatorMarkupEngine::digestRemarkupContent($this, $content); } diff --git a/src/applications/differential/storage/DifferentialInlineComment.php b/src/applications/differential/storage/DifferentialInlineComment.php index c27d59bbe3..bdc231671f 100644 --- a/src/applications/differential/storage/DifferentialInlineComment.php +++ b/src/applications/differential/storage/DifferentialInlineComment.php @@ -260,8 +260,8 @@ final class DifferentialInlineComment public function getMarkupFieldKey($field) { - // We can't use ID because synthetic comments don't have it. - return 'DI:'.PhabricatorHash::digest($this->getContent()); + $content = $this->getMarkupText($field); + return PhabricatorMarkupEngine::digestRemarkupContent($this, $content); } public function newMarkupEngine($field) { diff --git a/src/applications/legalpad/storage/LegalpadDocumentBody.php b/src/applications/legalpad/storage/LegalpadDocumentBody.php index a3fdf20f5f..001e38ebf3 100644 --- a/src/applications/legalpad/storage/LegalpadDocumentBody.php +++ b/src/applications/legalpad/storage/LegalpadDocumentBody.php @@ -39,8 +39,8 @@ final class LegalpadDocumentBody extends LegalpadDAO public function getMarkupFieldKey($field) { - $hash = PhabricatorHash::digest($this->getMarkupText($field)); - return 'LEGB:'.$hash; + $content = $this->getMarkupText($field); + return PhabricatorMarkupEngine::digestRemarkupContent($this, $content); } public function newMarkupEngine($field) { diff --git a/src/applications/maniphest/storage/ManiphestTask.php b/src/applications/maniphest/storage/ManiphestTask.php index ebcdef691d..16937da2f2 100644 --- a/src/applications/maniphest/storage/ManiphestTask.php +++ b/src/applications/maniphest/storage/ManiphestTask.php @@ -301,9 +301,8 @@ final class ManiphestTask extends ManiphestDAO * @task markup */ public function getMarkupFieldKey($field) { - $hash = PhabricatorHash::digest($this->getMarkupText($field)); - $id = $this->getID(); - return "maniphest:T{$id}:{$field}:{$hash}"; + $content = $this->getMarkupText($field); + return PhabricatorMarkupEngine::digestRemarkupContent($this, $content); } diff --git a/src/applications/phame/storage/PhameBlog.php b/src/applications/phame/storage/PhameBlog.php index 32cb6db543..bd4954d0ab 100644 --- a/src/applications/phame/storage/PhameBlog.php +++ b/src/applications/phame/storage/PhameBlog.php @@ -289,8 +289,8 @@ final class PhameBlog extends PhameDAO public function getMarkupFieldKey($field) { - $hash = PhabricatorHash::digest($this->getMarkupText($field)); - return $this->getPHID().':'.$field.':'.$hash; + $content = $this->getMarkupText($field); + return PhabricatorMarkupEngine::digestRemarkupContent($this, $content); } diff --git a/src/applications/phame/storage/PhamePost.php b/src/applications/phame/storage/PhamePost.php index 6e9e005bfa..f87a37e7a4 100644 --- a/src/applications/phame/storage/PhamePost.php +++ b/src/applications/phame/storage/PhamePost.php @@ -241,8 +241,8 @@ final class PhamePost extends PhameDAO public function getMarkupFieldKey($field) { - $hash = PhabricatorHash::digest($this->getMarkupText($field)); - return $this->getPHID().':'.$field.':'.$hash; + $content = $this->getMarkupText($field); + return PhabricatorMarkupEngine::digestRemarkupContent($this, $content); } public function newMarkupEngine($field) { diff --git a/src/applications/pholio/storage/PholioImage.php b/src/applications/pholio/storage/PholioImage.php index e81c71a05a..70f6e8b8c4 100644 --- a/src/applications/pholio/storage/PholioImage.php +++ b/src/applications/pholio/storage/PholioImage.php @@ -84,8 +84,8 @@ final class PholioImage extends PholioDAO public function getMarkupFieldKey($field) { - $hash = PhabricatorHash::digest($this->getMarkupText($field)); - return 'M:'.$hash; + $content = $this->getMarkupText($field); + return PhabricatorMarkupEngine::digestRemarkupContent($this, $content); } public function newMarkupEngine($field) { diff --git a/src/applications/pholio/storage/PholioMock.php b/src/applications/pholio/storage/PholioMock.php index 00e8efd981..7f58a95511 100644 --- a/src/applications/pholio/storage/PholioMock.php +++ b/src/applications/pholio/storage/PholioMock.php @@ -217,8 +217,8 @@ final class PholioMock extends PholioDAO public function getMarkupFieldKey($field) { - $hash = PhabricatorHash::digest($this->getMarkupText($field)); - return 'M:'.$hash; + $content = $this->getMarkupText($field); + return PhabricatorMarkupEngine::digestRemarkupContent($this, $content); } public function newMarkupEngine($field) { diff --git a/src/applications/phriction/storage/PhrictionContent.php b/src/applications/phriction/storage/PhrictionContent.php index 3a2e20aa29..0492534797 100644 --- a/src/applications/phriction/storage/PhrictionContent.php +++ b/src/applications/phriction/storage/PhrictionContent.php @@ -68,12 +68,8 @@ final class PhrictionContent extends PhrictionDAO * @task markup */ public function getMarkupFieldKey($field) { - if ($this->shouldUseMarkupCache($field)) { - $id = $this->getID(); - } else { - $id = PhabricatorHash::digest($this->getMarkupText($field)); - } - return "phriction:{$field}:{$id}"; + $content = $this->getMarkupText($field); + return PhabricatorMarkupEngine::digestRemarkupContent($this, $content); } diff --git a/src/applications/ponder/storage/PonderAnswer.php b/src/applications/ponder/storage/PonderAnswer.php index 76c9057497..f9e3e8eb8d 100644 --- a/src/applications/ponder/storage/PonderAnswer.php +++ b/src/applications/ponder/storage/PonderAnswer.php @@ -136,9 +136,8 @@ final class PonderAnswer extends PonderDAO // Markup interface public function getMarkupFieldKey($field) { - $hash = PhabricatorHash::digest($this->getMarkupText($field)); - $id = $this->getID(); - return "ponder:A{$id}:{$field}:{$hash}"; + $content = $this->getMarkupText($field); + return PhabricatorMarkupEngine::digestRemarkupContent($this, $content); } public function getMarkupText($field) { diff --git a/src/applications/ponder/storage/PonderQuestion.php b/src/applications/ponder/storage/PonderQuestion.php index d302bbfc29..6594219f5a 100644 --- a/src/applications/ponder/storage/PonderQuestion.php +++ b/src/applications/ponder/storage/PonderQuestion.php @@ -155,9 +155,8 @@ final class PonderQuestion extends PonderDAO // Markup interface public function getMarkupFieldKey($field) { - $hash = PhabricatorHash::digest($this->getMarkupText($field)); - $id = $this->getID(); - return "ponder:Q{$id}:{$field}:{$hash}"; + $content = $this->getMarkupText($field); + return PhabricatorMarkupEngine::digestRemarkupContent($this, $content); } public function getMarkupText($field) { diff --git a/src/applications/releeph/field/specification/ReleephFieldSpecification.php b/src/applications/releeph/field/specification/ReleephFieldSpecification.php index df458ced56..ff95ed6514 100644 --- a/src/applications/releeph/field/specification/ReleephFieldSpecification.php +++ b/src/applications/releeph/field/specification/ReleephFieldSpecification.php @@ -236,12 +236,14 @@ abstract class ReleephFieldSpecification } final public function getMarkupFieldKey($field) { - return sprintf( + $content = sprintf( '%s:%s:%s:%s', $this->getReleephRequest()->getPHID(), $this->getStorageKey(), $field, - PhabricatorHash::digest($this->getMarkupText($field))); + $this->getMarkupText($field)); + + return PhabricatorMarkupEngine::digestRemarkupContent($this, $content); } final public function newMarkupEngine($field) { diff --git a/src/infrastructure/markup/PhabricatorMarkupEngine.php b/src/infrastructure/markup/PhabricatorMarkupEngine.php index 3fbf29c294..ad380414f6 100644 --- a/src/infrastructure/markup/PhabricatorMarkupEngine.php +++ b/src/infrastructure/markup/PhabricatorMarkupEngine.php @@ -694,4 +694,19 @@ final class PhabricatorMarkupEngine extends Phobject { ->execute(); } + public static function digestRemarkupContent($object, $content) { + $parts = array(); + $parts[] = get_class($object); + + if ($object instanceof PhabricatorLiskDAO) { + $parts[] = $object->getID(); + } + + $parts[] = $content; + + $message = implode("\n", $parts); + + return PhabricatorHash::digestWithNamedKey($message, 'remarkup'); + } + }