1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 09:18:48 +02:00

Invert include/exclude logic on DivinerAtomQuery

Summary: Fixes T8401. Change `withIncludeGhosts()` to `withExcludeGhosts()` and `withIncludeUndocumentable()` to `withExcludeDocumentable()`. In particular, this allows querying for atoms by PHID to work as expected.

Test Plan: I got confused with double negatives so I might have gotten some of these wrong... I poked around Diviner and re-generated documentation to verify that this is working as expected.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T8401

Differential Revision: https://secure.phabricator.com/D13157
This commit is contained in:
Joshua Spence 2015-06-05 07:00:41 +10:00
parent 0fc0af6443
commit 32f669d566
6 changed files with 27 additions and 22 deletions

View file

@ -47,6 +47,8 @@ final class DivinerAtomController extends DivinerController {
->withNames(array($this->atomName))
->withContexts(array($this->atomContext))
->withIndexes(array($this->atomIndex))
->withGhosts(false)
->withIsDocumentable(true)
->needAtoms(true)
->needExtends(true)
->needChildren(true)

View file

@ -46,6 +46,8 @@ final class DivinerBookController extends DivinerController {
$atoms = id(new DivinerAtomQuery())
->setViewer($viewer)
->withBookPHIDs(array($book->getPHID()))
->withGhosts(false)
->withIsDocumentable(true)
->execute();
$atoms = msort($atoms, 'getSortKey');

View file

@ -41,6 +41,9 @@ final class DivinerFindController extends DivinerController {
$query->withTypes(array($type));
}
$query->withGhosts(false);
$query->withIsDocumentable(true);
$name_query = clone $query;
$name_query->withNames(

View file

@ -64,7 +64,7 @@ final class DivinerLivePublisher extends DivinerPublisher {
$symbols = id(new DivinerAtomQuery())
->setViewer(PhabricatorUser::getOmnipotentUser())
->withBookPHIDs(array($this->loadBook()->getPHID()))
->withIncludeUndocumentable(true)
->withGhosts(false)
->execute();
return mpull($symbols, 'getGraphHash');

View file

@ -9,8 +9,8 @@ final class DivinerAtomQuery extends PhabricatorCursorPagedPolicyAwareQuery {
private $types;
private $contexts;
private $indexes;
private $includeUndocumentable;
private $includeGhosts;
private $isDocumentable;
private $isGhost;
private $nodeHashes;
private $titles;
private $nameContains;
@ -81,9 +81,9 @@ final class DivinerAtomQuery extends PhabricatorCursorPagedPolicyAwareQuery {
/**
* Include "ghosts", which are symbols which used to exist but do not exist
* currently (for example, a function which existed in an older version of
* the codebase but was deleted).
* Include or exclude "ghosts", which are symbols which used to exist but do
* not exist currently (for example, a function which existed in an older
* version of the codebase but was deleted).
*
* These symbols had PHIDs assigned to them, and may have other sorts of
* metadata that we don't want to lose (like comments or flags), so we don't
@ -92,14 +92,11 @@ final class DivinerAtomQuery extends PhabricatorCursorPagedPolicyAwareQuery {
* have been generated incorrectly by accident. In these cases, we can
* restore the original data.
*
* However, most callers are not interested in these symbols, so they are
* excluded by default. You can use this method to include them in results.
*
* @param bool True to include ghosts.
* @param bool
* @return this
*/
public function withIncludeGhosts($include) {
$this->includeGhosts = $include;
public function withGhosts($ghosts) {
$this->isGhost = $ghosts;
return $this;
}
@ -108,8 +105,8 @@ final class DivinerAtomQuery extends PhabricatorCursorPagedPolicyAwareQuery {
return $this;
}
public function withIncludeUndocumentable($include) {
$this->includeUndocumentable = $include;
public function withIsDocumentable($documentable) {
$this->isDocumentable = $documentable;
return $this;
}
@ -346,16 +343,19 @@ final class DivinerAtomQuery extends PhabricatorCursorPagedPolicyAwareQuery {
$this->indexes);
}
if (!$this->includeUndocumentable) {
if ($this->isDocumentable !== null) {
$where[] = qsprintf(
$conn_r,
'isDocumentable = 1');
'isDocumentable = %d',
(int)$this->isDocumentable);
}
if (!$this->includeGhosts) {
$where[] = qsprintf(
$conn_r,
'graphHash IS NOT NULL');
if ($this->isGhost !== null) {
if ($this->isGhost) {
$where[] = qsprintf($conn_r, 'graphHash IS NULL');
} else {
$where[] = qsprintf($conn_r, 'graphHash IS NOT NULL');
}
}
if ($this->nodeHashes) {

View file

@ -93,8 +93,6 @@ final class DivinerLiveBook extends DivinerDAO
$atoms = id(new DivinerAtomQuery())
->setViewer($engine->getViewer())
->withBookPHIDs(array($this->getPHID()))
->withIncludeGhosts(true)
->withIncludeUndocumentable(true)
->execute();
foreach ($atoms as $atom) {