@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.

Title/Description quering for Passphrase credential

Summary: Fixes T6562, Title/Description querying for Passphrase

Test Plan: Open Passphrase, open advanced queries, enter a title and/or description. Search results should show credentials matching the search.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T6562

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

authored by

lkassianik and committed by
epriestley
edc4c219 d5e7cd55

+73 -3
+2
src/__phutil_library_map__.php
··· 1186 1186 'PassphraseRemarkupRule' => 'applications/passphrase/remarkup/PassphraseRemarkupRule.php', 1187 1187 'PassphraseSSHKey' => 'applications/passphrase/keys/PassphraseSSHKey.php', 1188 1188 'PassphraseSchemaSpec' => 'applications/passphrase/storage/PassphraseSchemaSpec.php', 1189 + 'PassphraseSearchIndexer' => 'applications/passphrase/search/PassphraseSearchIndexer.php', 1189 1190 'PassphraseSecret' => 'applications/passphrase/storage/PassphraseSecret.php', 1190 1191 'PasteConduitAPIMethod' => 'applications/paste/conduit/PasteConduitAPIMethod.php', 1191 1192 'PasteCreateConduitAPIMethod' => 'applications/paste/conduit/PasteCreateConduitAPIMethod.php', ··· 4280 4281 'PassphraseRemarkupRule' => 'PhabricatorObjectRemarkupRule', 4281 4282 'PassphraseSSHKey' => 'PassphraseAbstractKey', 4282 4283 'PassphraseSchemaSpec' => 'PhabricatorConfigSchemaSpec', 4284 + 'PassphraseSearchIndexer' => 'PhabricatorSearchDocumentIndexer', 4283 4285 'PassphraseSecret' => 'PassphraseDAO', 4284 4286 'PasteConduitAPIMethod' => 'ConduitAPIMethod', 4285 4287 'PasteCreateConduitAPIMethod' => 'PasteConduitAPIMethod',
+3 -1
src/applications/passphrase/editor/PassphraseCredentialTransactionEditor.php
··· 202 202 return $errors; 203 203 } 204 204 205 - 205 + protected function supportsSearch() { 206 + return true; 207 + } 206 208 }
+13
src/applications/passphrase/query/PassphraseCredentialQuery.php
··· 9 9 private $providesTypes; 10 10 private $isDestroyed; 11 11 private $allowConduit; 12 + private $nameContains; 12 13 13 14 private $needSecrets; 14 15 ··· 39 40 40 41 public function withAllowConduit($allow_conduit) { 41 42 $this->allowConduit = $allow_conduit; 43 + return $this; 44 + } 45 + 46 + public function withNameContains($name_contains) { 47 + $this->nameContains = $name_contains; 42 48 return $this; 43 49 } 44 50 ··· 138 144 $conn_r, 139 145 'allowConduit = %d', 140 146 (int)$this->allowConduit); 147 + } 148 + 149 + if (strlen($this->nameContains)) { 150 + $where[] = qsprintf( 151 + $conn_r, 152 + 'name LIKE %~', 153 + $this->nameContains); 141 154 } 142 155 143 156 return $this->formatWhereClause($where);
+16 -2
src/applications/passphrase/query/PassphraseCredentialSearchEngine.php
··· 17 17 $saved->setParameter( 18 18 'isDestroyed', 19 19 $this->readBoolFromRequest($request, 'isDestroyed')); 20 + $saved->setParameter('name', $request->getStr('name')); 20 21 21 22 return $saved; 22 23 } ··· 29 30 $query->withIsDestroyed($destroyed); 30 31 } 31 32 33 + $name = $saved->getParameter('name'); 34 + if (strlen($name)) { 35 + $query->withNameContains($name); 36 + } 37 + 32 38 return $query; 33 39 } 34 40 ··· 36 42 AphrontFormView $form, 37 43 PhabricatorSavedQuery $saved_query) { 38 44 39 - $form->appendChild( 45 + $name = $saved_query->getParameter('name'); 46 + 47 + $form 48 + ->appendChild( 40 49 id(new AphrontFormSelectControl()) 41 50 ->setName('isDestroyed') 42 51 ->setLabel(pht('Status')) ··· 46 55 '' => pht('Show All Credentials'), 47 56 'false' => pht('Show Only Active Credentials'), 48 57 'true' => pht('Show Only Destroyed Credentials'), 49 - ))); 58 + ))) 59 + ->appendChild( 60 + id(new AphrontFormTextControl()) 61 + ->setName('name') 62 + ->setLabel(pht('Name Contains')) 63 + ->setValue($name)); 50 64 } 51 65 52 66 protected function getURI($path) {
+39
src/applications/passphrase/search/PassphraseSearchIndexer.php
··· 1 + <?php 2 + 3 + final class PassphraseSearchIndexer extends PhabricatorSearchDocumentIndexer { 4 + 5 + public function getIndexableObject() { 6 + return new PassphraseCredential(); 7 + } 8 + 9 + protected function buildAbstractDocumentByPHID($phid) { 10 + $credential = $this->loadDocumentByPHID($phid); 11 + 12 + $doc = new PhabricatorSearchAbstractDocument(); 13 + $doc->setPHID($credential->getPHID()); 14 + $doc->setDocumentType(PassphraseCredentialPHIDType::TYPECONST); 15 + $doc->setDocumentTitle($credential->getName()); 16 + $doc->setDocumentCreated($credential->getDateCreated()); 17 + $doc->setDocumentModified($credential->getDateModified()); 18 + 19 + $doc->addField( 20 + PhabricatorSearchField::FIELD_BODY, 21 + $credential->getDescription()); 22 + 23 + $doc->addRelationship( 24 + $credential->getIsDestroyed() 25 + ? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED 26 + : PhabricatorSearchRelationship::RELATIONSHIP_OPEN, 27 + $credential->getPHID(), 28 + PassphraseCredentialPHIDType::TYPECONST, 29 + time()); 30 + 31 + $this->indexTransactions( 32 + $doc, 33 + new PassphraseCredentialTransactionQuery(), 34 + array($phid)); 35 + 36 + return $doc; 37 + } 38 + 39 + }