mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-09 16:32:39 +01:00
Support Ferret engine for Passphrase credentials
Summary: Ref T12819. Adds Ferret support to Passphrase. Test Plan: Indexed credentials, searched for credentials. Reviewers: chad Reviewed By: chad Maniphest Tasks: T12819 Differential Revision: https://secure.phabricator.com/D18556
This commit is contained in:
parent
f23717b416
commit
2020c1e7bd
10 changed files with 116 additions and 8 deletions
|
@ -0,0 +1,9 @@
|
|||
CREATE TABLE {$NAMESPACE}_passphrase.passphrase_credential_fdocument (
|
||||
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
objectPHID VARBINARY(64) NOT NULL,
|
||||
isClosed BOOL NOT NULL,
|
||||
authorPHID VARBINARY(64),
|
||||
ownerPHID VARBINARY(64),
|
||||
epochCreated INT UNSIGNED NOT NULL,
|
||||
epochModified INT UNSIGNED NOT NULL
|
||||
) ENGINE=InnoDB, COLLATE {$COLLATE_TEXT};
|
|
@ -0,0 +1,8 @@
|
|||
CREATE TABLE {$NAMESPACE}_passphrase.passphrase_credential_ffield (
|
||||
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
documentID INT UNSIGNED NOT NULL,
|
||||
fieldKey VARCHAR(4) NOT NULL COLLATE {$COLLATE_TEXT},
|
||||
rawCorpus LONGTEXT NOT NULL COLLATE {$COLLATE_SORT},
|
||||
termCorpus LONGTEXT NOT NULL COLLATE {$COLLATE_SORT},
|
||||
normalCorpus LONGTEXT NOT NULL COLLATE {$COLLATE_SORT}
|
||||
) ENGINE=InnoDB, COLLATE {$COLLATE_TEXT};
|
|
@ -0,0 +1,5 @@
|
|||
CREATE TABLE {$NAMESPACE}_passphrase.passphrase_credential_fngrams (
|
||||
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
documentID INT UNSIGNED NOT NULL,
|
||||
ngram CHAR(3) NOT NULL COLLATE {$COLLATE_TEXT}
|
||||
) ENGINE=InnoDB, COLLATE {$COLLATE_TEXT};
|
|
@ -1840,6 +1840,10 @@ phutil_register_library_map(array(
|
|||
'PassphraseCredentialDestroyController' => 'applications/passphrase/controller/PassphraseCredentialDestroyController.php',
|
||||
'PassphraseCredentialDestroyTransaction' => 'applications/passphrase/xaction/PassphraseCredentialDestroyTransaction.php',
|
||||
'PassphraseCredentialEditController' => 'applications/passphrase/controller/PassphraseCredentialEditController.php',
|
||||
'PassphraseCredentialFerretDocument' => 'applications/passphrase/storage/PassphraseCredentialFerretDocument.php',
|
||||
'PassphraseCredentialFerretEngine' => 'applications/passphrase/search/PassphraseCredentialFerretEngine.php',
|
||||
'PassphraseCredentialFerretField' => 'applications/passphrase/storage/PassphraseCredentialFerretField.php',
|
||||
'PassphraseCredentialFerretNgrams' => 'applications/passphrase/storage/PassphraseCredentialFerretNgrams.php',
|
||||
'PassphraseCredentialFulltextEngine' => 'applications/passphrase/search/PassphraseCredentialFulltextEngine.php',
|
||||
'PassphraseCredentialListController' => 'applications/passphrase/controller/PassphraseCredentialListController.php',
|
||||
'PassphraseCredentialLockController' => 'applications/passphrase/controller/PassphraseCredentialLockController.php',
|
||||
|
@ -7034,6 +7038,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorDestructibleInterface',
|
||||
'PhabricatorSpacesInterface',
|
||||
'PhabricatorFulltextInterface',
|
||||
'PhabricatorFerretInterface',
|
||||
),
|
||||
'PassphraseCredentialAuthorPolicyRule' => 'PhabricatorPolicyRule',
|
||||
'PassphraseCredentialConduitController' => 'PassphraseController',
|
||||
|
@ -7044,6 +7049,10 @@ phutil_register_library_map(array(
|
|||
'PassphraseCredentialDestroyController' => 'PassphraseController',
|
||||
'PassphraseCredentialDestroyTransaction' => 'PassphraseCredentialTransactionType',
|
||||
'PassphraseCredentialEditController' => 'PassphraseController',
|
||||
'PassphraseCredentialFerretDocument' => 'PhabricatorFerretDocument',
|
||||
'PassphraseCredentialFerretEngine' => 'PhabricatorFerretEngine',
|
||||
'PassphraseCredentialFerretField' => 'PhabricatorFerretField',
|
||||
'PassphraseCredentialFerretNgrams' => 'PhabricatorFerretNgrams',
|
||||
'PassphraseCredentialFulltextEngine' => 'PhabricatorFulltextEngine',
|
||||
'PassphraseCredentialListController' => 'PassphraseController',
|
||||
'PassphraseCredentialLockController' => 'PassphraseController',
|
||||
|
|
|
@ -109,49 +109,49 @@ final class PassphraseCredentialQuery
|
|||
if ($this->ids !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn,
|
||||
'id IN (%Ld)',
|
||||
'c.id IN (%Ld)',
|
||||
$this->ids);
|
||||
}
|
||||
|
||||
if ($this->phids !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn,
|
||||
'phid IN (%Ls)',
|
||||
'c.phid IN (%Ls)',
|
||||
$this->phids);
|
||||
}
|
||||
|
||||
if ($this->credentialTypes !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn,
|
||||
'credentialType in (%Ls)',
|
||||
'c.credentialType in (%Ls)',
|
||||
$this->credentialTypes);
|
||||
}
|
||||
|
||||
if ($this->providesTypes !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn,
|
||||
'providesType IN (%Ls)',
|
||||
'c.providesType IN (%Ls)',
|
||||
$this->providesTypes);
|
||||
}
|
||||
|
||||
if ($this->isDestroyed !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn,
|
||||
'isDestroyed = %d',
|
||||
'c.isDestroyed = %d',
|
||||
(int)$this->isDestroyed);
|
||||
}
|
||||
|
||||
if ($this->allowConduit !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn,
|
||||
'allowConduit = %d',
|
||||
'c.allowConduit = %d',
|
||||
(int)$this->allowConduit);
|
||||
}
|
||||
|
||||
if (strlen($this->nameContains)) {
|
||||
$where[] = qsprintf(
|
||||
$conn,
|
||||
'LOWER(name) LIKE %~',
|
||||
'LOWER(c.name) LIKE %~',
|
||||
phutil_utf8_strtolower($this->nameContains));
|
||||
}
|
||||
|
||||
|
@ -162,4 +162,8 @@ final class PassphraseCredentialQuery
|
|||
return 'PhabricatorPassphraseApplication';
|
||||
}
|
||||
|
||||
protected function getPrimaryTableAlias() {
|
||||
return 'c';
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
final class PassphraseCredentialFerretEngine
|
||||
extends PhabricatorFerretEngine {
|
||||
|
||||
public function newNgramsObject() {
|
||||
return new PassphraseCredentialFerretNgrams();
|
||||
}
|
||||
|
||||
public function newDocumentObject() {
|
||||
return new PassphraseCredentialFerretDocument();
|
||||
}
|
||||
|
||||
public function newFieldObject() {
|
||||
return new PassphraseCredentialFerretField();
|
||||
}
|
||||
|
||||
public function newSearchEngine() {
|
||||
return new PassphraseCredentialSearchEngine();
|
||||
}
|
||||
|
||||
}
|
|
@ -8,7 +8,8 @@ final class PassphraseCredential extends PassphraseDAO
|
|||
PhabricatorSubscribableInterface,
|
||||
PhabricatorDestructibleInterface,
|
||||
PhabricatorSpacesInterface,
|
||||
PhabricatorFulltextInterface {
|
||||
PhabricatorFulltextInterface,
|
||||
PhabricatorFerretInterface {
|
||||
|
||||
protected $name;
|
||||
protected $credentialType;
|
||||
|
@ -197,4 +198,12 @@ final class PassphraseCredential extends PassphraseDAO
|
|||
}
|
||||
|
||||
|
||||
/* -( PhabricatorFerretInterface )----------------------------------------- */
|
||||
|
||||
|
||||
public function newFerretEngine() {
|
||||
return new PassphraseCredentialFerretEngine();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
final class PassphraseCredentialFerretDocument
|
||||
extends PhabricatorFerretDocument {
|
||||
|
||||
public function getApplicationName() {
|
||||
return 'passphrase';
|
||||
}
|
||||
|
||||
public function getIndexKey() {
|
||||
return 'credential';
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
final class PassphraseCredentialFerretField
|
||||
extends PhabricatorFerretField {
|
||||
|
||||
public function getApplicationName() {
|
||||
return 'passphrase';
|
||||
}
|
||||
|
||||
public function getIndexKey() {
|
||||
return 'credential';
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
final class PassphraseCredentialFerretNgrams
|
||||
extends PhabricatorFerretNgrams {
|
||||
|
||||
public function getApplicationName() {
|
||||
return 'passphrase';
|
||||
}
|
||||
|
||||
public function getIndexKey() {
|
||||
return 'credential';
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue