diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 627558ae2b..ab47959b25 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -519,6 +519,7 @@ phutil_register_library_map(array( 'PhabricatorSearchIndexController' => 'applications/search/controller/index', 'PhabricatorSearchManiphestIndexer' => 'applications/search/index/indexer/maniphest', 'PhabricatorSearchMySQLExecutor' => 'applications/search/execute/mysql', + 'PhabricatorSearchPhrictionIndexer' => 'applications/search/index/indexer/phriction', 'PhabricatorSearchQuery' => 'applications/search/storage/query', 'PhabricatorSearchRelationship' => 'applications/search/constants/relationship', 'PhabricatorSearchResultView' => 'applications/search/view/searchresult', @@ -1022,6 +1023,7 @@ phutil_register_library_map(array( 'PhabricatorSearchIndexController' => 'PhabricatorSearchBaseController', 'PhabricatorSearchManiphestIndexer' => 'PhabricatorSearchDocumentIndexer', 'PhabricatorSearchMySQLExecutor' => 'PhabricatorSearchExecutor', + 'PhabricatorSearchPhrictionIndexer' => 'PhabricatorSearchDocumentIndexer', 'PhabricatorSearchQuery' => 'PhabricatorSearchDAO', 'PhabricatorSearchResultView' => 'AphrontView', 'PhabricatorSearchSelectController' => 'PhabricatorSearchController', diff --git a/src/applications/phid/handle/PhabricatorObjectHandle.php b/src/applications/phid/handle/PhabricatorObjectHandle.php index edd8193f95..3b1b88de1c 100644 --- a/src/applications/phid/handle/PhabricatorObjectHandle.php +++ b/src/applications/phid/handle/PhabricatorObjectHandle.php @@ -118,6 +118,7 @@ class PhabricatorObjectHandle { PhabricatorPHIDConstants::PHID_TYPE_TASK => 'Task', PhabricatorPHIDConstants::PHID_TYPE_DREV => 'Revision', PhabricatorPHIDConstants::PHID_TYPE_CMIT => 'Commit', + PhabricatorPHIDConstants::PHID_TYPE_WIKI => 'Phriction', ); return idx($map, $this->getType()); diff --git a/src/applications/phid/handle/data/PhabricatorObjectHandleData.php b/src/applications/phid/handle/data/PhabricatorObjectHandleData.php index 072cdafacc..f105c99fcd 100644 --- a/src/applications/phid/handle/data/PhabricatorObjectHandleData.php +++ b/src/applications/phid/handle/data/PhabricatorObjectHandleData.php @@ -345,6 +345,35 @@ class PhabricatorObjectHandleData { $handles[$phid] = $handle; } break; + case PhabricatorPHIDConstants::PHID_TYPE_WIKI: + $document_dao = newv('PhrictionDocument', array()); + $content_dao = newv('PhrictionContent', array()); + + $conn = $document_dao->establishConnection('r'); + $documents = queryfx_all( + $conn, + 'SELECT * FROM %T document JOIN %T content + ON document.contentID = content.id + WHERE document.phid IN (%Ls)', + $document_dao->getTableName(), + $content_dao->getTableName(), + $phids); + $documents = ipull($documents, null, 'phid'); + + foreach ($phids as $phid) { + $handle = new PhabricatorObjectHandle(); + $handle->setPHID($phid); + $handle->setType($type); + if (empty($documents[$phid])) { + $handle->setName('Unknown Document'); + } else { + $info = $documents[$phid]; + $handle->setName($info['title']); + $handle->setURI(PhrictionDocument::getSlugURI($info['slug'])); + } + $handles[$phid] = $handle; + } + break; default: $loader = null; if (isset($external_loaders[$type])) { diff --git a/src/applications/phid/handle/data/__init__.php b/src/applications/phid/handle/data/__init__.php index 4ad54490fa..da94fb9894 100644 --- a/src/applications/phid/handle/data/__init__.php +++ b/src/applications/phid/handle/data/__init__.php @@ -10,9 +10,11 @@ phutil_require_module('phabricator', 'applications/files/uri'); phutil_require_module('phabricator', 'applications/maniphest/constants/owner'); phutil_require_module('phabricator', 'applications/phid/constants'); phutil_require_module('phabricator', 'applications/phid/handle'); +phutil_require_module('phabricator', 'applications/phriction/storage/document'); phutil_require_module('phabricator', 'applications/repository/constants/repositorytype'); phutil_require_module('phabricator', 'applications/repository/storage/repository'); phutil_require_module('phabricator', 'infrastructure/env'); +phutil_require_module('phabricator', 'storage/queryfx'); phutil_require_module('phutil', 'symbols'); phutil_require_module('phutil', 'utils'); diff --git a/src/applications/phriction/controller/edit/PhrictionEditController.php b/src/applications/phriction/controller/edit/PhrictionEditController.php index 645cd9a08c..06834c741d 100644 --- a/src/applications/phriction/controller/edit/PhrictionEditController.php +++ b/src/applications/phriction/controller/edit/PhrictionEditController.php @@ -104,6 +104,9 @@ class PhrictionEditController $document->setContentID($new_content->getID()); $document->save(); + $document->attachContent($new_content); + PhabricatorSearchPhrictionIndexer::indexDocument($document); + $uri = PhrictionDocument::getSlugURI($document->getSlug()); return id(new AphrontRedirectResponse())->setURI($uri); } diff --git a/src/applications/phriction/controller/edit/__init__.php b/src/applications/phriction/controller/edit/__init__.php index 8c9ca92237..306f152475 100644 --- a/src/applications/phriction/controller/edit/__init__.php +++ b/src/applications/phriction/controller/edit/__init__.php @@ -11,6 +11,7 @@ phutil_require_module('phabricator', 'aphront/response/redirect'); phutil_require_module('phabricator', 'applications/phriction/controller/base'); phutil_require_module('phabricator', 'applications/phriction/storage/content'); phutil_require_module('phabricator', 'applications/phriction/storage/document'); +phutil_require_module('phabricator', 'applications/search/index/indexer/phriction'); phutil_require_module('phabricator', 'infrastructure/env'); phutil_require_module('phabricator', 'view/form/base'); phutil_require_module('phabricator', 'view/form/control/static'); diff --git a/src/applications/search/controller/search/PhabricatorSearchController.php b/src/applications/search/controller/search/PhabricatorSearchController.php index 3f63a75c43..2b28c123a4 100644 --- a/src/applications/search/controller/search/PhabricatorSearchController.php +++ b/src/applications/search/controller/search/PhabricatorSearchController.php @@ -72,6 +72,7 @@ class PhabricatorSearchController extends PhabricatorSearchBaseController { PhabricatorPHIDConstants::PHID_TYPE_DREV => 'Differential Revisions', PhabricatorPHIDConstants::PHID_TYPE_CMIT => 'Repository Commits', PhabricatorPHIDConstants::PHID_TYPE_TASK => 'Maniphest Tasks', + PhabricatorPHIDConstants::PHID_TYPE_WIKI => 'Phriction Documents', PhabricatorPHIDConstants::PHID_TYPE_USER => 'Phabricator Users', ) + $more; diff --git a/src/applications/search/index/indexer/phriction/PhabricatorSearchPhrictionIndexer.php b/src/applications/search/index/indexer/phriction/PhabricatorSearchPhrictionIndexer.php new file mode 100644 index 0000000000..c16c66f181 --- /dev/null +++ b/src/applications/search/index/indexer/phriction/PhabricatorSearchPhrictionIndexer.php @@ -0,0 +1,46 @@ +getContent(); + + $doc = new PhabricatorSearchAbstractDocument(); + $doc->setPHID($document->getPHID()); + $doc->setDocumentType(PhabricatorPHIDConstants::PHID_TYPE_WIKI); + $doc->setDocumentTitle($content->getTitle()); + + // TODO: This isn't precisely correct, denormalize into the Document table? + $doc->setDocumentCreated($content->getDateCreated()); + $doc->setDocumentModified($content->getDateModified()); + + $doc->addField( + PhabricatorSearchField::FIELD_BODY, + $content->getContent()); + + $doc->addRelationship( + PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, + $content->getAuthorPHID(), + PhabricatorPHIDConstants::PHID_TYPE_USER, + $content->getDateCreated()); + + PhabricatorSearchDocument::reindexAbstractDocument($doc); + } +} diff --git a/src/applications/search/index/indexer/phriction/__init__.php b/src/applications/search/index/indexer/phriction/__init__.php new file mode 100644 index 0000000000..3db665a13d --- /dev/null +++ b/src/applications/search/index/indexer/phriction/__init__.php @@ -0,0 +1,17 @@ +