1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-27 01:02:42 +01:00

Purge loadRelativeEdges

Summary:
Fixes T3821. Maybe. The existing code seemed to have a bug and actually return the //commit phid//. Judging by the function name this is not intended.

Also, sorry to step on toes here -- I thought no one was assigned and was curious about loadRelativeEdges and here we are...

Test Plan: lots of logic here as I have no idea how to use Releeph.

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran

Maniphest Tasks: T3821

Differential Revision: https://secure.phabricator.com/D6967
This commit is contained in:
Bob Trahan 2013-09-13 11:40:52 -07:00
parent c41c593388
commit ea0dc5625d
4 changed files with 8 additions and 75 deletions

View file

@ -207,13 +207,15 @@ final class ReleephRequest extends ReleephDAO
}
public function loadRequestCommitDiffPHID() {
$phids = array();
$commit = $this->loadPhabricatorRepositoryCommit();
if ($commit) {
$edges = $this
->loadPhabricatorRepositoryCommit()
->loadRelativeEdges(PhabricatorEdgeConfig::TYPE_COMMIT_HAS_DREV);
return head(array_keys($edges));
$phids = PhabricatorEdgeQuery::loadDestinationPHIDs(
$commit->getPHID(),
PhabricatorEdgeConfig::TYPE_COMMIT_HAS_DREV);
}
return head($phids);
}

View file

@ -150,8 +150,7 @@ final class PhabricatorEdgeQuery extends PhabricatorQuery {
$result = array();
// When a query specifies types, make sure we return data for all queried
// types. This is mostly to make sure PhabricatorLiskDAO->attachEdges()
// gets some data, so that getEdges() doesn't throw later.
// types.
if ($this->edgeTypes) {
foreach ($this->sourcePHIDs as $phid) {
foreach ($this->edgeTypes as $type) {

View file

@ -23,11 +23,10 @@
final class LiskDAOSet {
private $daos = array();
private $relatives = array();
private $edges = array();
private $subsets = array();
public function addToSet(LiskDAO $dao) {
if ($this->relatives || $this->edges) {
if ($this->relatives) {
throw new Exception("Don't call addToSet() after loading data!");
}
$this->daos[] = $dao;
@ -42,7 +41,6 @@ final class LiskDAOSet {
final public function clearSet() {
$this->daos = array();
$this->relatives = array();
$this->edges = array();
foreach ($this->subsets as $set) {
$set->clearSet();
}
@ -88,26 +86,4 @@ final class LiskDAOSet {
return $relatives;
}
public function loadRelativeEdges($type) {
$edges = &$this->edges[$type];
if ($edges === null) {
if (!$this->daos) {
$edges = array();
} else {
assert_instances_of($this->daos, 'PhabricatorLiskDAO');
$phids = mpull($this->daos, 'getPHID', 'getPHID');
$edges = id(new PhabricatorEdgeQuery())
->withSourcePHIDs($phids)
->withEdgeTypes(array($type))
->execute();
foreach ($this->daos as $dao) {
$dao->attachEdges($edges[$dao->getPHID()]);
}
}
}
return $edges;
}
}

View file

@ -1,58 +1,14 @@
<?php
/**
* @task edges Managing Edges
* @task config Configuring Storage
*/
abstract class PhabricatorLiskDAO extends LiskDAO {
private $edges = array();
private static $namespaceStack = array();
const ATTACHABLE = "<attachable>";
/* -( Managing Edges )----------------------------------------------------- */
/**
* @task edges
*/
public function attachEdges(array $edges) {
foreach ($edges as $type => $type_edges) {
$this->edges[$type] = $type_edges;
}
return $this;
}
/**
* @task edges
*/
public function getEdges($type) {
return $this->assertAttachedKey($this->edges, $type);
}
/**
* @task edges
*/
public function loadRelativeEdges($type) {
if (!$this->getInSet()) {
id(new LiskDAOSet())->addToSet($this);
}
$this->getInSet()->loadRelativeEdges($type);
return $this->getEdges($type);
}
/**
* @task edges
*/
public function getEdgePHIDs($type) {
return ipull($this->getEdges($type), 'dst');
}
/* -( Configuring Storage )------------------------------------------------ */
/**