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

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

+27 -22
+2
src/applications/diviner/controller/DivinerAtomController.php
··· 47 47 ->withNames(array($this->atomName)) 48 48 ->withContexts(array($this->atomContext)) 49 49 ->withIndexes(array($this->atomIndex)) 50 + ->withGhosts(false) 51 + ->withIsDocumentable(true) 50 52 ->needAtoms(true) 51 53 ->needExtends(true) 52 54 ->needChildren(true)
+2
src/applications/diviner/controller/DivinerBookController.php
··· 46 46 $atoms = id(new DivinerAtomQuery()) 47 47 ->setViewer($viewer) 48 48 ->withBookPHIDs(array($book->getPHID())) 49 + ->withGhosts(false) 50 + ->withIsDocumentable(true) 49 51 ->execute(); 50 52 51 53 $atoms = msort($atoms, 'getSortKey');
+3
src/applications/diviner/controller/DivinerFindController.php
··· 41 41 $query->withTypes(array($type)); 42 42 } 43 43 44 + $query->withGhosts(false); 45 + $query->withIsDocumentable(true); 46 + 44 47 $name_query = clone $query; 45 48 46 49 $name_query->withNames(
+1 -1
src/applications/diviner/publisher/DivinerLivePublisher.php
··· 64 64 $symbols = id(new DivinerAtomQuery()) 65 65 ->setViewer(PhabricatorUser::getOmnipotentUser()) 66 66 ->withBookPHIDs(array($this->loadBook()->getPHID())) 67 - ->withIncludeUndocumentable(true) 67 + ->withGhosts(false) 68 68 ->execute(); 69 69 70 70 return mpull($symbols, 'getGraphHash');
+19 -19
src/applications/diviner/query/DivinerAtomQuery.php
··· 9 9 private $types; 10 10 private $contexts; 11 11 private $indexes; 12 - private $includeUndocumentable; 13 - private $includeGhosts; 12 + private $isDocumentable; 13 + private $isGhost; 14 14 private $nodeHashes; 15 15 private $titles; 16 16 private $nameContains; ··· 81 81 82 82 83 83 /** 84 - * Include "ghosts", which are symbols which used to exist but do not exist 85 - * currently (for example, a function which existed in an older version of 86 - * the codebase but was deleted). 84 + * Include or exclude "ghosts", which are symbols which used to exist but do 85 + * not exist currently (for example, a function which existed in an older 86 + * version of the codebase but was deleted). 87 87 * 88 88 * These symbols had PHIDs assigned to them, and may have other sorts of 89 89 * metadata that we don't want to lose (like comments or flags), so we don't ··· 92 92 * have been generated incorrectly by accident. In these cases, we can 93 93 * restore the original data. 94 94 * 95 - * However, most callers are not interested in these symbols, so they are 96 - * excluded by default. You can use this method to include them in results. 97 - * 98 - * @param bool True to include ghosts. 95 + * @param bool 99 96 * @return this 100 97 */ 101 - public function withIncludeGhosts($include) { 102 - $this->includeGhosts = $include; 98 + public function withGhosts($ghosts) { 99 + $this->isGhost = $ghosts; 103 100 return $this; 104 101 } 105 102 ··· 108 105 return $this; 109 106 } 110 107 111 - public function withIncludeUndocumentable($include) { 112 - $this->includeUndocumentable = $include; 108 + public function withIsDocumentable($documentable) { 109 + $this->isDocumentable = $documentable; 113 110 return $this; 114 111 } 115 112 ··· 346 343 $this->indexes); 347 344 } 348 345 349 - if (!$this->includeUndocumentable) { 346 + if ($this->isDocumentable !== null) { 350 347 $where[] = qsprintf( 351 348 $conn_r, 352 - 'isDocumentable = 1'); 349 + 'isDocumentable = %d', 350 + (int)$this->isDocumentable); 353 351 } 354 352 355 - if (!$this->includeGhosts) { 356 - $where[] = qsprintf( 357 - $conn_r, 358 - 'graphHash IS NOT NULL'); 353 + if ($this->isGhost !== null) { 354 + if ($this->isGhost) { 355 + $where[] = qsprintf($conn_r, 'graphHash IS NULL'); 356 + } else { 357 + $where[] = qsprintf($conn_r, 'graphHash IS NOT NULL'); 358 + } 359 359 } 360 360 361 361 if ($this->nodeHashes) {
-2
src/applications/diviner/storage/DivinerLiveBook.php
··· 93 93 $atoms = id(new DivinerAtomQuery()) 94 94 ->setViewer($engine->getViewer()) 95 95 ->withBookPHIDs(array($this->getPHID())) 96 - ->withIncludeGhosts(true) 97 - ->withIncludeUndocumentable(true) 98 96 ->execute(); 99 97 100 98 foreach ($atoms as $atom) {