Differential D17149 Diff 41246 src/applications/search/query/PhabricatorProfileMenuItemConfigurationQuery.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/search/query/PhabricatorProfileMenuItemConfigurationQuery.php
<?php | <?php | ||||
final class PhabricatorProfileMenuItemConfigurationQuery | final class PhabricatorProfileMenuItemConfigurationQuery | ||||
extends PhabricatorCursorPagedPolicyAwareQuery { | extends PhabricatorCursorPagedPolicyAwareQuery { | ||||
private $ids; | private $ids; | ||||
private $phids; | private $phids; | ||||
private $profilePHIDs; | private $profilePHIDs; | ||||
private $customPHIDs; | |||||
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 withProfilePHIDs(array $phids) { | public function withProfilePHIDs(array $phids) { | ||||
$this->profilePHIDs = $phids; | $this->profilePHIDs = $phids; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function withCustomPHIDs(array $phids) { | |||||
$this->customPHIDs = $phids; | |||||
return $this; | |||||
} | |||||
public function newResultObject() { | public function newResultObject() { | ||||
return new PhabricatorProfileMenuItemConfiguration(); | return new PhabricatorProfileMenuItemConfiguration(); | ||||
} | } | ||||
protected function loadPage() { | protected function loadPage() { | ||||
return $this->loadStandardPage($this->newResultObject()); | return $this->loadStandardPage($this->newResultObject()); | ||||
} | } | ||||
Show All 16 Lines | protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { | ||||
if ($this->profilePHIDs !== null) { | if ($this->profilePHIDs !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn, | $conn, | ||||
'profilePHID IN (%Ls)', | 'profilePHID IN (%Ls)', | ||||
$this->profilePHIDs); | $this->profilePHIDs); | ||||
} | } | ||||
if ($this->customPHIDs !== null) { | |||||
$where[] = qsprintf( | |||||
$conn, | |||||
'customPHID IN (%Ls)', | |||||
$this->customPHIDs); | |||||
} | |||||
return $where; | return $where; | ||||
} | } | ||||
protected function willFilterPage(array $page) { | protected function willFilterPage(array $page) { | ||||
$items = PhabricatorProfileMenuItem::getAllMenuItems(); | $items = PhabricatorProfileMenuItem::getAllMenuItems(); | ||||
foreach ($page as $key => $item) { | foreach ($page as $key => $item) { | ||||
$item_type = idx($items, $item->getMenuItemKey()); | $item_type = idx($items, $item->getMenuItemKey()); | ||||
if (!$item_type) { | if (!$item_type) { | ||||
Show All 23 Lines | foreach ($page as $key => $item) { | ||||
if (!$profile) { | if (!$profile) { | ||||
$this->didRejectResult($item); | $this->didRejectResult($item); | ||||
unset($page[$key]); | unset($page[$key]); | ||||
continue; | continue; | ||||
} | } | ||||
$item->attachProfileObject($profile); | $item->attachProfileObject($profile); | ||||
} | } | ||||
return $page; | return $page; | ||||
} | } | ||||
public function getQueryApplicationClass() { | public function getQueryApplicationClass() { | ||||
return 'PhabricatorSearchApplication'; | return 'PhabricatorSearchApplication'; | ||||
} | } | ||||
} | } | ||||
epriestley: I think this will do the wrong thing for items with no custom PHID. It will incorrectly reject… |
I think this will do the wrong thing for items with no custom PHID. It will incorrectly reject them because it can't load the objects, but it's valid to have no customPHID.
I also think we probably don't need this -- it will make the query a little slower and I think we won't ever actually access the custom objects, and don't need to perform policy checks on them.