Page MenuHomePhabricator

D14775.diff
No OneTemporary

D14775.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -2616,6 +2616,7 @@
'PhabricatorOwnersPackageTransactionQuery' => 'applications/owners/query/PhabricatorOwnersPackageTransactionQuery.php',
'PhabricatorOwnersPath' => 'applications/owners/storage/PhabricatorOwnersPath.php',
'PhabricatorOwnersPathsController' => 'applications/owners/controller/PhabricatorOwnersPathsController.php',
+ 'PhabricatorOwnersPathsSearchEngineAttachment' => 'applications/owners/engineextension/PhabricatorOwnersPathsSearchEngineAttachment.php',
'PhabricatorOwnersSchemaSpec' => 'applications/owners/storage/PhabricatorOwnersSchemaSpec.php',
'PhabricatorOwnersSearchField' => 'applications/owners/searchfield/PhabricatorOwnersSearchField.php',
'PhabricatorPHDConfigOptions' => 'applications/config/option/PhabricatorPHDConfigOptions.php',
@@ -6846,6 +6847,7 @@
'PhabricatorOwnersPackageTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'PhabricatorOwnersPath' => 'PhabricatorOwnersDAO',
'PhabricatorOwnersPathsController' => 'PhabricatorOwnersController',
+ 'PhabricatorOwnersPathsSearchEngineAttachment' => 'PhabricatorSearchEngineAttachment',
'PhabricatorOwnersSchemaSpec' => 'PhabricatorConfigSchemaSpec',
'PhabricatorOwnersSearchField' => 'PhabricatorSearchTokenizerField',
'PhabricatorPHDConfigOptions' => 'PhabricatorApplicationConfigOptions',
diff --git a/src/applications/owners/controller/PhabricatorOwnersDetailController.php b/src/applications/owners/controller/PhabricatorOwnersDetailController.php
--- a/src/applications/owners/controller/PhabricatorOwnersDetailController.php
+++ b/src/applications/owners/controller/PhabricatorOwnersDetailController.php
@@ -14,7 +14,6 @@
->setViewer($viewer)
->withIDs(array($request->getURIData('id')))
->needPaths(true)
- ->needOwners(true)
->executeOne();
if (!$package) {
return new Aphront404Response();
diff --git a/src/applications/owners/editor/PhabricatorOwnersPackageEditEngine.php b/src/applications/owners/editor/PhabricatorOwnersPackageEditEngine.php
--- a/src/applications/owners/editor/PhabricatorOwnersPackageEditEngine.php
+++ b/src/applications/owners/editor/PhabricatorOwnersPackageEditEngine.php
@@ -18,8 +18,7 @@
}
protected function newObjectQuery() {
- return id(new PhabricatorOwnersPackageQuery())
- ->needOwners(true);
+ return id(new PhabricatorOwnersPackageQuery());
}
protected function getObjectCreateTitleText($object) {
diff --git a/src/applications/owners/editor/PhabricatorOwnersPackageTransactionEditor.php b/src/applications/owners/editor/PhabricatorOwnersPackageTransactionEditor.php
--- a/src/applications/owners/editor/PhabricatorOwnersPackageTransactionEditor.php
+++ b/src/applications/owners/editor/PhabricatorOwnersPackageTransactionEditor.php
@@ -32,8 +32,7 @@
case PhabricatorOwnersPackageTransaction::TYPE_NAME:
return $object->getName();
case PhabricatorOwnersPackageTransaction::TYPE_OWNERS:
- // TODO: needOwners() this on the Query.
- $phids = mpull($object->loadOwners(), 'getUserPHID');
+ $phids = mpull($object->getOwners(), 'getUserPHID');
$phids = array_values($phids);
return $phids;
case PhabricatorOwnersPackageTransaction::TYPE_AUDITING:
@@ -125,8 +124,7 @@
$old = $xaction->getOldValue();
$new = $xaction->getNewValue();
- // TODO: needOwners this
- $owners = $object->loadOwners();
+ $owners = $object->getOwners();
$owners = mpull($owners, null, 'getUserPHID');
$rem = array_diff($old, $new);
@@ -222,8 +220,7 @@
}
protected function getMailCC(PhabricatorLiskDAO $object) {
- // TODO: needOwners() this
- return mpull($object->loadOwners(), 'getUserPHID');
+ return mpull($object->getOwners(), 'getUserPHID');
}
protected function buildReplyHandler(PhabricatorLiskDAO $object) {
diff --git a/src/applications/owners/engineextension/PhabricatorOwnersPathsSearchEngineAttachment.php b/src/applications/owners/engineextension/PhabricatorOwnersPathsSearchEngineAttachment.php
new file mode 100644
--- /dev/null
+++ b/src/applications/owners/engineextension/PhabricatorOwnersPathsSearchEngineAttachment.php
@@ -0,0 +1,35 @@
+<?php
+
+final class PhabricatorOwnersPathsSearchEngineAttachment
+ extends PhabricatorSearchEngineAttachment {
+
+ public function getAttachmentName() {
+ return pht('Included Paths');
+ }
+
+ public function getAttachmentDescription() {
+ return pht('Get the paths for each package.');
+ }
+
+ public function willLoadAttachmentData($query, $spec) {
+ $query->needPaths(true);
+ }
+
+ public function getAttachmentForObject($object, $data, $spec) {
+ $paths = $object->getPaths();
+
+ $list = array();
+ foreach ($paths as $path) {
+ $list[] = array(
+ 'repositoryPHID' => $path->getRepositoryPHID(),
+ 'path' => $path->getPath(),
+ 'isExcluded' => (bool)$path->getExcluded(),
+ );
+ }
+
+ return array(
+ 'paths' => $list,
+ );
+ }
+
+}
diff --git a/src/applications/owners/query/PhabricatorOwnersPackageQuery.php b/src/applications/owners/query/PhabricatorOwnersPackageQuery.php
--- a/src/applications/owners/query/PhabricatorOwnersPackageQuery.php
+++ b/src/applications/owners/query/PhabricatorOwnersPackageQuery.php
@@ -16,7 +16,6 @@
private $controlResults;
private $needPaths;
- private $needOwners;
/**
@@ -89,11 +88,6 @@
return $this;
}
- public function needOwners($need_owners) {
- $this->needOwners = $need_owners;
- return $this;
- }
-
public function newResultObject() {
return new PhabricatorOwnersPackage();
}
@@ -103,13 +97,27 @@
}
protected function loadPage() {
- return $this->loadStandardPage(new PhabricatorOwnersPackage());
+ return $this->loadStandardPage($this->newResultObject());
+ }
+
+ protected function willFilterPage(array $packages) {
+ $package_ids = mpull($packages, 'getID');
+
+ $owners = id(new PhabricatorOwnersOwner())->loadAllWhere(
+ 'packageID IN (%Ld)',
+ $package_ids);
+ $owners = mgroup($owners, 'getPackageID');
+ foreach ($packages as $package) {
+ $package->attachOwners(idx($owners, $package->getID(), array()));
+ }
+
+ return $packages;
}
protected function didFilterPage(array $packages) {
- if ($this->needPaths) {
- $package_ids = mpull($packages, 'getID');
+ $package_ids = mpull($packages, 'getID');
+ if ($this->needPaths) {
$paths = id(new PhabricatorOwnersPath())->loadAllWhere(
'packageID IN (%Ld)',
$package_ids);
@@ -120,19 +128,6 @@
}
}
- if ($this->needOwners) {
- $package_ids = mpull($packages, 'getID');
-
- $owners = id(new PhabricatorOwnersOwner())->loadAllWhere(
- 'packageID IN (%Ld)',
- $package_ids);
- $owners = mgroup($owners, 'getPackageID');
-
- foreach ($packages as $package) {
- $package->attachOwners(idx($owners, $package->getID(), array()));
- }
- }
-
if ($this->controlMap) {
$this->controlResults += mpull($packages, null, 'getID');
}
diff --git a/src/applications/owners/storage/PhabricatorOwnersPackage.php b/src/applications/owners/storage/PhabricatorOwnersPackage.php
--- a/src/applications/owners/storage/PhabricatorOwnersPackage.php
+++ b/src/applications/owners/storage/PhabricatorOwnersPackage.php
@@ -273,6 +273,17 @@
return mpull($this->getOwners(), 'getUserPHID');
}
+ public function isOwnerPHID($phid) {
+ if (!$phid) {
+ return false;
+ }
+
+ $owner_phids = $this->getOwnerPHIDs();
+ $owner_phids = array_fuse($owner_phids);
+
+ return isset($owner_phids[$phid]);
+ }
+
/* -( PhabricatorPolicyInterface )----------------------------------------- */
@@ -290,11 +301,19 @@
}
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
+ switch ($capability) {
+ case PhabricatorPolicyCapability::CAN_VIEW:
+ if ($this->isOwnerPHID($viewer->getPHID())) {
+ return true;
+ }
+ break;
+ }
+
return false;
}
public function describeAutomaticCapability($capability) {
- return null;
+ return pht('Owners of a package may always view it.');
}
@@ -384,19 +403,34 @@
'type' => 'string',
'description' => pht('Active or archived status of the package.'),
),
+ 'owners' => array(
+ 'type' => 'list<map<string, wild>>',
+ 'description' => pht('List of package owners.'),
+ ),
);
}
public function getFieldValuesForConduit() {
+ $owner_list = array();
+ foreach ($this->getOwners() as $owner) {
+ $owner_list[] = array(
+ 'ownerPHID' => $owner->getUserPHID(),
+ );
+ }
+
return array(
'name' => $this->getName(),
'description' => $this->getDescription(),
'status' => $this->getStatus(),
+ 'owners' => $owner_list,
);
}
public function getConduitSearchAttachments() {
- return array();
+ return array(
+ id(new PhabricatorOwnersPathsSearchEngineAttachment())
+ ->setAttachmentKey('paths'),
+ );
}
}
diff --git a/src/applications/paste/engineextension/PhabricatorPasteContentSearchEngineAttachment.php b/src/applications/paste/engineextension/PhabricatorPasteContentSearchEngineAttachment.php
--- a/src/applications/paste/engineextension/PhabricatorPasteContentSearchEngineAttachment.php
+++ b/src/applications/paste/engineextension/PhabricatorPasteContentSearchEngineAttachment.php
@@ -17,7 +17,7 @@
public function getAttachmentForObject($object, $data, $spec) {
return array(
- 'data' => $object->getRawContent(),
+ 'content' => $object->getRawContent(),
);
}

File Metadata

Mime Type
text/plain
Expires
Thu, Oct 17, 12:36 PM (3 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6722089
Default Alt Text
D14775.diff (9 KB)

Event Timeline