diff --git a/resources/sql/patches/harbormasterobject.sql b/resources/sql/patches/harbormasterobject.sql index c1eb93cb2c..f252ae8e5e 100644 --- a/resources/sql/patches/harbormasterobject.sql +++ b/resources/sql/patches/harbormasterobject.sql @@ -4,7 +4,7 @@ CREATE TABLE {$NAMESPACE}_harbormaster.harbormaster_object ( name VARCHAR(255) COLLATE utf8_general_ci, dateCreated INT UNSIGNED NOT NULL, dateModified INT UNSIGNED NOT NULL -); +) ENGINE=InnoDB, COLLATE utf8_general_ci; CREATE TABLE {$NAMESPACE}_harbormaster.edge ( src VARCHAR(64) NOT NULL COLLATE utf8_bin, diff --git a/resources/sql/patches/markupcache.sql b/resources/sql/patches/markupcache.sql new file mode 100644 index 0000000000..e13a236f25 --- /dev/null +++ b/resources/sql/patches/markupcache.sql @@ -0,0 +1,10 @@ +CREATE TABLE {$NAMESPACE}_cache.cache_markupcache ( + id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, + cacheKey VARCHAR(128) NOT NULL collate utf8_bin, + cacheData LONGTEXT NOT NULL COLLATE utf8_bin, + metadata LONGTEXT NOT NULL COLLATE utf8_bin, + dateCreated INT UNSIGNED NOT NULL, + dateModified INT UNSIGNED NOT NULL, + UNIQUE KEY (cacheKey), + KEY (dateCreated) +) ENGINE=InnoDB, COLLATE utf8_general_ci; diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 60ca2aa07f..a7510a5d9d 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -563,6 +563,7 @@ phutil_register_library_map(array( 'PhabricatorAuthController' => 'applications/auth/controller/PhabricatorAuthController.php', 'PhabricatorBaseEnglishTranslation' => 'infrastructure/internationalization/PhabricatorBaseEnglishTranslation.php', 'PhabricatorBuiltinPatchList' => 'infrastructure/storage/patch/PhabricatorBuiltinPatchList.php', + 'PhabricatorCacheDAO' => 'applications/cache/storage/PhabricatorCacheDAO.php', 'PhabricatorCalendarBrowseController' => 'applications/calendar/controller/PhabricatorCalendarBrowseController.php', 'PhabricatorCalendarController' => 'applications/calendar/controller/PhabricatorCalendarController.php', 'PhabricatorCalendarDAO' => 'applications/calendar/storage/PhabricatorCalendarDAO.php', @@ -738,7 +739,9 @@ phutil_register_library_map(array( 'PhabricatorMailImplementationSendGridAdapter' => 'applications/metamta/adapter/PhabricatorMailImplementationSendGridAdapter.php', 'PhabricatorMailImplementationTestAdapter' => 'applications/metamta/adapter/PhabricatorMailImplementationTestAdapter.php', 'PhabricatorMailReplyHandler' => 'applications/metamta/replyhandler/PhabricatorMailReplyHandler.php', + 'PhabricatorMarkupCache' => 'applications/cache/storage/PhabricatorMarkupCache.php', 'PhabricatorMarkupEngine' => 'infrastructure/markup/PhabricatorMarkupEngine.php', + 'PhabricatorMarkupInterface' => 'infrastructure/markup/PhabricatorMarkupInterface.php', 'PhabricatorMercurialGraphStream' => 'applications/repository/daemon/PhabricatorMercurialGraphStream.php', 'PhabricatorMetaMTAAttachment' => 'applications/metamta/storage/PhabricatorMetaMTAAttachment.php', 'PhabricatorMetaMTAController' => 'applications/metamta/controller/PhabricatorMetaMTAController.php', @@ -1590,6 +1593,7 @@ phutil_register_library_map(array( 'PhabricatorAuthController' => 'PhabricatorController', 'PhabricatorBaseEnglishTranslation' => 'PhabricatorTranslation', 'PhabricatorBuiltinPatchList' => 'PhabricatorSQLPatchList', + 'PhabricatorCacheDAO' => 'PhabricatorLiskDAO', 'PhabricatorCalendarBrowseController' => 'PhabricatorCalendarController', 'PhabricatorCalendarController' => 'PhabricatorController', 'PhabricatorCalendarDAO' => 'PhabricatorLiskDAO', @@ -1742,6 +1746,7 @@ phutil_register_library_map(array( 'PhabricatorMailImplementationPHPMailerLiteAdapter' => 'PhabricatorMailImplementationAdapter', 'PhabricatorMailImplementationSendGridAdapter' => 'PhabricatorMailImplementationAdapter', 'PhabricatorMailImplementationTestAdapter' => 'PhabricatorMailImplementationAdapter', + 'PhabricatorMarkupCache' => 'PhabricatorCacheDAO', 'PhabricatorMetaMTAController' => 'PhabricatorController', 'PhabricatorMetaMTADAO' => 'PhabricatorLiskDAO', 'PhabricatorMetaMTAEmailBodyParserTestCase' => 'PhabricatorTestCase', @@ -2037,7 +2042,11 @@ phutil_register_library_map(array( 'PhrictionDAO' => 'PhabricatorLiskDAO', 'PhrictionDeleteController' => 'PhrictionController', 'PhrictionDiffController' => 'PhrictionController', - 'PhrictionDocument' => 'PhrictionDAO', + 'PhrictionDocument' => + array( + 0 => 'PhrictionDAO', + 1 => 'PhabricatorMarkupInterface', + ), 'PhrictionDocumentController' => 'PhrictionController', 'PhrictionDocumentPreviewController' => 'PhrictionController', 'PhrictionDocumentStatus' => 'PhrictionConstants', diff --git a/src/applications/cache/storage/PhabricatorCacheDAO.php b/src/applications/cache/storage/PhabricatorCacheDAO.php new file mode 100644 index 0000000000..4d4dc4a72f --- /dev/null +++ b/src/applications/cache/storage/PhabricatorCacheDAO.php @@ -0,0 +1,25 @@ + array( + 'cacheData' => self::SERIALIZATION_PHP, + 'metadata' => self::SERIALIZATION_JSON, + ), + ) + parent::getConfiguration(); + } + +} diff --git a/src/applications/phriction/controller/PhrictionHistoryController.php b/src/applications/phriction/controller/PhrictionHistoryController.php index c6af894098..e266a6d7a0 100644 --- a/src/applications/phriction/controller/PhrictionHistoryController.php +++ b/src/applications/phriction/controller/PhrictionHistoryController.php @@ -61,7 +61,7 @@ final class PhrictionHistoryController $rows = array(); foreach ($history as $content) { - $uri = PhrictionDocument::getSlugURI($document->getSlug()); + $slug_uri = PhrictionDocument::getSlugURI($document->getSlug()); $version = $content->getVersion(); $diff_uri = new PhutilURI('/phriction/diff/'.$document->getID().'/'); @@ -102,7 +102,7 @@ final class PhrictionHistoryController phutil_render_tag( 'a', array( - 'href' => $uri.'?v='.$version, + 'href' => $slug_uri.'?v='.$version, ), 'Version '.$version), $handles[$content->getAuthorPHID()]->renderLink(), diff --git a/src/applications/phriction/storage/PhrictionContent.php b/src/applications/phriction/storage/PhrictionContent.php index b03e731906..da84fb1ce0 100644 --- a/src/applications/phriction/storage/PhrictionContent.php +++ b/src/applications/phriction/storage/PhrictionContent.php @@ -17,9 +17,14 @@ */ /** + * @task markup Markup Interface + * * @group phriction */ -final class PhrictionContent extends PhrictionDAO { +final class PhrictionContent extends PhrictionDAO + implements PhabricatorMarkupInterface { + + const MARKUP_FIELD_BODY = 'markup:body'; protected $id; protected $documentID; @@ -35,11 +40,55 @@ final class PhrictionContent extends PhrictionDAO { protected $changeRef; public function renderContent() { - $engine = PhabricatorMarkupEngine::newPhrictionMarkupEngine(); - $markup = $engine->markupText($this->getContent()); + return PhabricatorMarkupEngine::renderOneObject( + $this, + self::MARKUP_FIELD_BODY); + } + + +/* -( Markup Interface )--------------------------------------------------- */ + + + /** + * @task markup + */ + public function getMarkupFieldKey($field) { + if ($this->shouldUseMarkupCache($field)) { + $id = $this->getID(); + } else { + $id = PhabricatorHash::digest($this->getMarkupText($field)); + } + return "phriction:{$field}:{$id}"; + } + + + /** + * @task markup + */ + public function getMarkupText($field) { + return $this->getContent(); + } + + + /** + * @task markup + */ + public function newMarkupEngine($field) { + return PhabricatorMarkupEngine::newPhrictionMarkupEngine(); + } + + + /** + * @task markup + */ + public function didMarkupText( + $field, + $output, + PhutilMarkupEngine $engine) { $toc = PhutilRemarkupEngineRemarkupHeaderBlockRule::renderTableOfContents( $engine); + if ($toc) { $toc = '