Changeset View
Changeset View
Standalone View
Standalone View
src/applications/pholio/query/PholioImageQuery.php
<?php | <?php | ||||
final class PholioImageQuery | final class PholioImageQuery | ||||
extends PhabricatorCursorPagedPolicyAwareQuery { | extends PhabricatorCursorPagedPolicyAwareQuery { | ||||
private $ids; | private $ids; | ||||
private $phids; | private $phids; | ||||
private $mockIDs; | private $mockPHIDs; | ||||
private $obsolete; | |||||
private $needInlineComments; | private $needInlineComments; | ||||
private $mockCache = array(); | private $mockCache = array(); | ||||
public function withIDs(array $ids) { | public function withIDs(array $ids) { | ||||
$this->ids = $ids; | $this->ids = $ids; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function withPHIDs(array $phids) { | public function withPHIDs(array $phids) { | ||||
$this->phids = $phids; | $this->phids = $phids; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function withMockIDs(array $mock_ids) { | public function withMockPHIDs(array $mock_phids) { | ||||
$this->mockIDs = $mock_ids; | $this->mockPHIDs = $mock_phids; | ||||
return $this; | |||||
} | |||||
public function withObsolete($obsolete) { | |||||
$this->obsolete = $obsolete; | |||||
return $this; | return $this; | ||||
} | } | ||||
epriestley: This has no callers, so I removed it for now. Previously, I believe Pholio only showed current… | |||||
public function needInlineComments($need_inline_comments) { | public function needInlineComments($need_inline_comments) { | ||||
$this->needInlineComments = $need_inline_comments; | $this->needInlineComments = $need_inline_comments; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setMockCache($mock_cache) { | public function setMockCache($mock_cache) { | ||||
$this->mockCache = $mock_cache; | $this->mockCache = $mock_cache; | ||||
Show All 23 Lines | protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { | ||||
if ($this->phids !== null) { | if ($this->phids !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn, | $conn, | ||||
'phid IN (%Ls)', | 'phid IN (%Ls)', | ||||
$this->phids); | $this->phids); | ||||
} | } | ||||
if ($this->mockIDs !== null) { | if ($this->mockPHIDs !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn, | $conn, | ||||
'mockID IN (%Ld)', | 'mockPHID IN (%Ls)', | ||||
$this->mockIDs); | $this->mockPHIDs); | ||||
} | |||||
if ($this->obsolete !== null) { | |||||
$where[] = qsprintf( | |||||
$conn, | |||||
'isObsolete = %d', | |||||
$this->obsolete); | |||||
} | } | ||||
return $where; | return $where; | ||||
} | } | ||||
protected function willFilterPage(array $images) { | protected function willFilterPage(array $images) { | ||||
assert_instances_of($images, 'PholioImage'); | assert_instances_of($images, 'PholioImage'); | ||||
if ($this->getMockCache()) { | if ($this->getMockCache()) { | ||||
$mocks = $this->getMockCache(); | $mocks = $this->getMockCache(); | ||||
} else { | } else { | ||||
$mock_ids = mpull($images, 'getMockID'); | $mock_phids = mpull($images, 'getMockPHID'); | ||||
// DO NOT set needImages to true; recursion results! | // DO NOT set needImages to true; recursion results! | ||||
$mocks = id(new PholioMockQuery()) | $mocks = id(new PholioMockQuery()) | ||||
->setViewer($this->getViewer()) | ->setViewer($this->getViewer()) | ||||
->withIDs($mock_ids) | ->withPHIDs($mock_phids) | ||||
->execute(); | ->execute(); | ||||
$mocks = mpull($mocks, null, 'getID'); | $mocks = mpull($mocks, null, 'getPHID'); | ||||
} | } | ||||
foreach ($images as $index => $image) { | foreach ($images as $index => $image) { | ||||
$mock = idx($mocks, $image->getMockID()); | $mock = idx($mocks, $image->getMockPHID()); | ||||
if ($mock) { | if ($mock) { | ||||
$image->attachMock($mock); | $image->attachMock($mock); | ||||
} else { | } else { | ||||
// mock is missing or we can't see it | // mock is missing or we can't see it | ||||
unset($images[$index]); | unset($images[$index]); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 45 Lines • Show Last 20 Lines |
This has no callers, so I removed it for now. Previously, I believe Pholio only showed current versions of images, so this probably dates to that earlier time.