@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
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Provide and populate an object name index for Maniphest

Summary: See discussion in D6955. This provides a table we can JOIN against to (effectively) "ORDER BY project name", populates it intially, and keeps it up to date as projects are edited.

Test Plan:
- Ran storage upgrade, verified projects populated into the table.
- Edited a project, verified its entry updated.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

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

+96
+9
resources/sql/patches/20130912.maniphest.3.nameindex.sql
··· 1 + CREATE TABLE {$NAMESPACE}_maniphest.maniphest_nameindex ( 2 + id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 3 + indexedObjectPHID VARCHAR(64) NOT NULL COLLATE utf8_bin, 4 + indexedObjectName VARCHAR(128) NOT NULL, 5 + 6 + UNIQUE KEY `key_phid` (indexedObjectPHID), 7 + KEY `key_name` (indexedObjectName) 8 + 9 + ) ENGINE=InnoDB, COLLATE utf8_general_ci;
+16
resources/sql/patches/20130912.maniphest.4.fillindex.php
··· 1 + <?php 2 + 3 + // Update the "PROJ" search index, to: 4 + // 5 + // - Populate the index itself, which was added recently. 6 + // - Populate the secondary object name index in Maniphest. 7 + 8 + $root = dirname(phutil_get_library_root('phabricator')); 9 + 10 + $command = new PhutilExecPassthru( 11 + 'php -f %s -- index --type PROJ', 12 + $root.'/scripts/search/manage_search.php'); 13 + $err = $command->execute(); 14 + if ($err) { 15 + throw new Exception("Update failed!"); 16 + }
+4
src/__phutil_library_map__.php
··· 698 698 'ManiphestExcelFormat' => 'applications/maniphest/export/ManiphestExcelFormat.php', 699 699 'ManiphestExportController' => 'applications/maniphest/controller/ManiphestExportController.php', 700 700 'ManiphestHovercardEventListener' => 'applications/maniphest/event/ManiphestHovercardEventListener.php', 701 + 'ManiphestNameIndex' => 'applications/maniphest/storage/ManiphestNameIndex.php', 702 + 'ManiphestNameIndexEventListener' => 'applications/maniphest/event/ManiphestNameIndexEventListener.php', 701 703 'ManiphestPHIDTypeTask' => 'applications/maniphest/phid/ManiphestPHIDTypeTask.php', 702 704 'ManiphestPeopleMenuEventListener' => 'applications/maniphest/event/ManiphestPeopleMenuEventListener.php', 703 705 'ManiphestRemarkupRule' => 'applications/maniphest/remarkup/ManiphestRemarkupRule.php', ··· 2762 2764 'ManiphestExcelDefaultFormat' => 'ManiphestExcelFormat', 2763 2765 'ManiphestExportController' => 'ManiphestController', 2764 2766 'ManiphestHovercardEventListener' => 'PhutilEventListener', 2767 + 'ManiphestNameIndex' => 'ManiphestDAO', 2768 + 'ManiphestNameIndexEventListener' => 'PhutilEventListener', 2765 2769 'ManiphestPHIDTypeTask' => 'PhabricatorPHIDType', 2766 2770 'ManiphestPeopleMenuEventListener' => 'PhutilEventListener', 2767 2771 'ManiphestRemarkupRule' => 'PhabricatorRemarkupRuleObject',
+1
src/applications/maniphest/application/PhabricatorApplicationManiphest.php
··· 34 34 35 35 public function getEventListeners() { 36 36 return array( 37 + new ManiphestNameIndexEventListener(), 37 38 new ManiphestPeopleMenuEventListener(), 38 39 new ManiphestHovercardEventListener(), 39 40 );
+25
src/applications/maniphest/event/ManiphestNameIndexEventListener.php
··· 1 + <?php 2 + 3 + final class ManiphestNameIndexEventListener extends PhutilEventListener { 4 + 5 + public function register() { 6 + $this->listen(PhabricatorEventType::TYPE_SEARCH_DIDUPDATEINDEX); 7 + } 8 + 9 + public function handleEvent(PhutilEvent $event) { 10 + $phid = $event->getValue('phid'); 11 + $type = phid_get_type($phid); 12 + 13 + // For now, we only index projects. 14 + if ($type != PhabricatorProjectPHIDTypeProject::TYPECONST) { 15 + return; 16 + } 17 + 18 + $document = $event->getValue('document'); 19 + 20 + ManiphestNameIndex::updateIndex( 21 + $phid, 22 + $document->getDocumentTitle()); 23 + } 24 + 25 + }
+30
src/applications/maniphest/storage/ManiphestNameIndex.php
··· 1 + <?php 2 + 3 + /** 4 + * Denormalizes object names to support queries which need to be ordered or 5 + * grouped by things like projects. 6 + */ 7 + final class ManiphestNameIndex extends ManiphestDAO { 8 + 9 + protected $indexedObjectPHID; 10 + protected $indexedObjectName; 11 + 12 + public function getConfiguration() { 13 + return array( 14 + self::CONFIG_TIMESTAMPS => false, 15 + ) + parent::getConfiguration(); 16 + } 17 + 18 + public static function updateIndex($phid, $name) { 19 + $table = new ManiphestNameIndex(); 20 + $conn_w = $table->establishConnection('w'); 21 + queryfx( 22 + $conn_w, 23 + 'INSERT INTO %T (indexedObjectPHID, indexedObjectName) VALUES (%s, %s) 24 + ON DUPLICATE KEY UPDATE indexedObjectName = VALUES(indexedObjectName)', 25 + $table->getTableName(), 26 + $phid, 27 + $name); 28 + } 29 + 30 + }
+3
src/applications/project/editor/PhabricatorProjectEditor.php
··· 166 166 throw $ex; 167 167 } 168 168 169 + id(new PhabricatorSearchIndexer()) 170 + ->indexDocumentByPHID($project->getPHID()); 171 + 169 172 return $this; 170 173 } 171 174
+8
src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php
··· 1580 1580 'type' => 'sql', 1581 1581 'name' => $this->getPatchPath('20130912.maniphest.2.created.sql'), 1582 1582 ), 1583 + '20130912.maniphest.3.nameindex.sql' => array( 1584 + 'type' => 'sql', 1585 + 'name' => $this->getPatchPath('20130912.maniphest.3.nameindex.sql'), 1586 + ), 1587 + '20130912.maniphest.4.fillindex.php' => array( 1588 + 'type' => 'php', 1589 + 'name' => $this->getPatchPath('20130912.maniphest.4.fillindex.php'), 1590 + ), 1583 1591 ); 1584 1592 } 1585 1593 }