Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phid/query/PhabricatorObjectQuery.php
Show First 20 Lines • Show All 100 Lines • ▼ Show 20 Lines | private function loadObjectsByName(array $types, array $names) { | ||||
} | } | ||||
return $results; | return $results; | ||||
} | } | ||||
private function loadObjectsByPHID(array $types, array $phids) { | private function loadObjectsByPHID(array $types, array $phids) { | ||||
$results = array(); | $results = array(); | ||||
$workspace = $this->getObjectsFromWorkspace($phids); | |||||
foreach ($phids as $key => $phid) { | |||||
if (isset($workspace[$phid])) { | |||||
$results[$phid] = $workspace[$phid]; | |||||
unset($phids[$key]); | |||||
} | |||||
} | |||||
if (!$phids) { | |||||
return $results; | |||||
} | |||||
$groups = array(); | $groups = array(); | ||||
foreach ($phids as $phid) { | foreach ($phids as $phid) { | ||||
$type = phid_get_type($phid); | $type = phid_get_type($phid); | ||||
$groups[$type][] = $phid; | $groups[$type][] = $phid; | ||||
} | } | ||||
$in_flight = $this->getPHIDsInFlight(); | $in_flight = $this->getPHIDsInFlight(); | ||||
foreach ($groups as $type => $group) { | foreach ($groups as $type => $group) { | ||||
// We check the workspace for each group, because some groups may trigger | |||||
// other groups to load (for example, transactions load their objects). | |||||
$workspace = $this->getObjectsFromWorkspace($group); | |||||
foreach ($group as $key => $phid) { | |||||
if (isset($workspace[$phid])) { | |||||
$results[$phid] = $workspace[$phid]; | |||||
unset($group[$key]); | |||||
} | |||||
} | |||||
if (!$group) { | |||||
continue; | |||||
} | |||||
// Don't try to load PHIDs which are already "in flight"; this prevents | // Don't try to load PHIDs which are already "in flight"; this prevents | ||||
// us from recursing indefinitely if policy checks or edges form a loop. | // us from recursing indefinitely if policy checks or edges form a loop. | ||||
// We will decline to load the corresponding objects. | // We will decline to load the corresponding objects. | ||||
foreach ($group as $key => $phid) { | foreach ($group as $key => $phid) { | ||||
if (isset($in_flight[$phid])) { | if (isset($in_flight[$phid])) { | ||||
unset($group[$key]); | unset($group[$key]); | ||||
} | } | ||||
} | } | ||||
if ($group && isset($types[$type])) { | if ($group && isset($types[$type])) { | ||||
$this->putPHIDsInFlight($group); | $this->putPHIDsInFlight($group); | ||||
$objects = $types[$type]->loadObjects($this, $group); | $objects = $types[$type]->loadObjects($this, $group); | ||||
$results += mpull($objects, null, 'getPHID'); | |||||
$map = mpull($objects, null, 'getPHID'); | |||||
$this->putObjectsInWorkspace($map); | |||||
$results += $map; | |||||
} | } | ||||
} | } | ||||
return $results; | return $results; | ||||
} | } | ||||
protected function didFilterResults(array $filtered) { | protected function didFilterResults(array $filtered) { | ||||
foreach ($this->namedResults as $name => $result) { | foreach ($this->namedResults as $name => $result) { | ||||
Show All 26 Lines |