Page MenuHomePhabricator

D13170.id.diff
No OneTemporary

D13170.id.diff

diff --git a/src/applications/paste/query/PhabricatorPasteSearchEngine.php b/src/applications/paste/query/PhabricatorPasteSearchEngine.php
--- a/src/applications/paste/query/PhabricatorPasteSearchEngine.php
+++ b/src/applications/paste/query/PhabricatorPasteSearchEngine.php
@@ -11,21 +11,24 @@
return 'PhabricatorPasteApplication';
}
- public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
+ public function buildQueryFromParameters(array $map) {
$query = id(new PhabricatorPasteQuery())
- ->needContent(true)
- ->withAuthorPHIDs($saved->getParameter('authorPHIDs', array()))
- ->withLanguages($saved->getParameter('languages', array()));
+ ->needContent(true);
- $start = $this->parseDateTime($saved->getParameter('createdStart'));
- $end = $this->parseDateTime($saved->getParameter('createdEnd'));
+ if ($map['authorPHIDs']) {
+ $query->withAuthorPHIDs($map['authorPHIDs']);
+ }
+
+ if ($map['languages']) {
+ $query->withLanguages($map['languages']);
+ }
- if ($start) {
- $query->withDateCreatedAfter($start);
+ if ($map['createdStart']) {
+ $query->withDateCreatedAfter($map['createdStart']);
}
- if ($end) {
- $query->withDateCreatedBefore($end);
+ if ($map['createdEnd']) {
+ $query->withDateCreatedBefore($map['createdEnd']);
}
return $query;
diff --git a/src/applications/search/engine/PhabricatorApplicationSearchEngine.php b/src/applications/search/engine/PhabricatorApplicationSearchEngine.php
--- a/src/applications/search/engine/PhabricatorApplicationSearchEngine.php
+++ b/src/applications/search/engine/PhabricatorApplicationSearchEngine.php
@@ -90,8 +90,24 @@
* @param PhabricatorSavedQuery The saved query to operate on.
* @return The result of the query.
*/
- abstract public function buildQueryFromSavedQuery(
- PhabricatorSavedQuery $saved);
+ public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
+ $fields = $this->buildSearchFields();
+ $viewer = $this->requireViewer();
+
+ $parameters = array();
+ foreach ($fields as $field) {
+ $field->setViewer($viewer);
+ $field->readValueFromSavedQuery($saved);
+ $value = $field->getValueForQuery($field->getValue());
+ $parameters[$field->getKey()] = $value;
+ }
+
+ return $this->buildQueryFromParameters($parameters);
+ }
+
+ protected function buildQueryFromParameters(array $parameters) {
+ throw new PhutilMethodNotImplementedException();
+ }
/**
* Builds the search form using the request.
diff --git a/src/applications/search/field/PhabricatorSearchDateField.php b/src/applications/search/field/PhabricatorSearchDateField.php
--- a/src/applications/search/field/PhabricatorSearchDateField.php
+++ b/src/applications/search/field/PhabricatorSearchDateField.php
@@ -11,6 +11,10 @@
return $request->getStr($key);
}
+ public function getValueForQuery($value) {
+ return $this->parseDateTime($value);
+ }
+
protected function validateControlValue($value) {
if (!strlen($value)) {
return;
diff --git a/src/applications/search/field/PhabricatorSearchField.php b/src/applications/search/field/PhabricatorSearchField.php
--- a/src/applications/search/field/PhabricatorSearchField.php
+++ b/src/applications/search/field/PhabricatorSearchField.php
@@ -201,6 +201,10 @@
return null;
}
+ public function getValueForQuery($value) {
+ return $value;
+ }
+
/* -( Rendering Controls )------------------------------------------------- */
diff --git a/src/applications/search/field/PhabricatorSearchTokenizerField.php b/src/applications/search/field/PhabricatorSearchTokenizerField.php
--- a/src/applications/search/field/PhabricatorSearchTokenizerField.php
+++ b/src/applications/search/field/PhabricatorSearchTokenizerField.php
@@ -11,11 +11,18 @@
return $this->getListFromRequest($request, $key);
}
+ public function getValueForQuery($value) {
+ return $this->newDatasource()
+ ->setViewer($this->getViewer())
+ ->evaluateTokens($value);
+ }
+
protected function newControl() {
return id(new AphrontFormTokenizerControl())
->setDatasource($this->newDatasource());
}
+
abstract protected function newDatasource();
}
diff --git a/src/applications/search/field/PhabricatorSearchUsersField.php b/src/applications/search/field/PhabricatorSearchUsersField.php
--- a/src/applications/search/field/PhabricatorSearchUsersField.php
+++ b/src/applications/search/field/PhabricatorSearchUsersField.php
@@ -8,9 +8,7 @@
}
protected function newDatasource() {
- // TODO: Make this use PhabricatorPeopleUserFunctionDatasource once field
- // support is a little more powerful.
- return new PhabricatorPeopleDatasource();
+ return new PhabricatorPeopleUserFunctionDatasource();
}
protected function getValueFromRequest(AphrontRequest $request, $key) {

File Metadata

Mime Type
text/plain
Expires
Sat, May 11, 8:40 AM (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6281753
Default Alt Text
D13170.id.diff (4 KB)

Event Timeline