diff --git a/resources/sql/autopatches/20151227.proj.01.materialize.sql b/resources/sql/autopatches/20151227.proj.01.materialize.sql new file mode 100644 --- /dev/null +++ b/resources/sql/autopatches/20151227.proj.01.materialize.sql @@ -0,0 +1,6 @@ +/* PhabricatorProjectProjectHasMemberEdgeType::EDGECONST = 13 */ +/* PhabricatorProjectMaterializedMemberEdgeType::EDGECONST = 60 */ + +INSERT IGNORE INTO {$NAMESPACE}_project.edge (src, type, dst, dateCreated) + SELECT src, 60, dst, dateCreated FROM {$NAMESPACE}_project.edge + WHERE type = 13; diff --git a/src/applications/owners/storage/PhabricatorOwnersOwner.php b/src/applications/owners/storage/PhabricatorOwnersOwner.php --- a/src/applications/owners/storage/PhabricatorOwnersOwner.php +++ b/src/applications/owners/storage/PhabricatorOwnersOwner.php @@ -40,6 +40,7 @@ if (!$package_ids) { return array(); } + $owners = id(new PhabricatorOwnersOwner())->loadAllWhere( 'packageID IN (%Ls)', $package_ids); @@ -50,20 +51,19 @@ PhabricatorPeopleUserPHIDType::TYPECONST, array()); - $users_in_project_phids = array(); - $project_phids = idx( - $all_phids, - PhabricatorProjectProjectPHIDType::TYPECONST); - if ($project_phids) { - $query = id(new PhabricatorEdgeQuery()) - ->withSourcePHIDs($project_phids) - ->withEdgeTypes(array( - PhabricatorProjectProjectHasMemberEdgeType::EDGECONST, - )); - $query->execute(); - $users_in_project_phids = $query->getDestinationPHIDs(); + if ($user_phids) { + $projects = id(new PhabricatorProjectQuery()) + ->setViewer(PhabricatorUser::getOmnipotentUser()) + ->withMemberPHIDs($user_phids) + ->withIsMilestone(false) + ->execute(); + $project_phids = mpull($projects, 'getPHID'); + } else { + $project_phids = array(); } - return array_unique(array_merge($users_in_project_phids, $user_phids)); + $all_phids = array_fuse($user_phids) + array_fuse($project_phids); + + return array_values($all_phids); } } diff --git a/src/applications/project/editor/PhabricatorProjectTransactionEditor.php b/src/applications/project/editor/PhabricatorProjectTransactionEditor.php --- a/src/applications/project/editor/PhabricatorProjectTransactionEditor.php +++ b/src/applications/project/editor/PhabricatorProjectTransactionEditor.php @@ -509,12 +509,13 @@ } protected function willPublish(PhabricatorLiskDAO $object, array $xactions) { - $member_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( - $object->getPHID(), - PhabricatorProjectProjectHasMemberEdgeType::EDGECONST); - $object->attachMemberPHIDs($member_phids); - - return $object; + // NOTE: We're using the omnipotent user here because the original actor + // may no longer have permission to view the object. + return id(new PhabricatorProjectQuery()) + ->setViewer(PhabricatorUser::getOmnipotentUser()) + ->withPHIDs(array($object->getPHID())) + ->needMembers(true) + ->executeOne(); } protected function shouldSendMail( @@ -719,9 +720,12 @@ $object_phid = $object->getPHID(); if ($object_phid) { - $members = PhabricatorEdgeQuery::loadDestinationPHIDs( - $object_phid, - PhabricatorProjectProjectHasMemberEdgeType::EDGECONST); + $project = id(new PhabricatorProjectQuery()) + ->setViewer($this->getActor()) + ->withPHIDs(array($object_phid)) + ->needMembers(true) + ->executeOne(); + $members = $project->getMemberPHIDs(); } else { $members = array(); } diff --git a/src/applications/project/query/PhabricatorProjectQuery.php b/src/applications/project/query/PhabricatorProjectQuery.php --- a/src/applications/project/query/PhabricatorProjectQuery.php +++ b/src/applications/project/query/PhabricatorProjectQuery.php @@ -201,11 +201,11 @@ $viewer_phid = $this->getViewer()->getPHID(); - $member_type = PhabricatorProjectProjectHasMemberEdgeType::EDGECONST; + $material_type = PhabricatorProjectMaterializedMemberEdgeType::EDGECONST; $watcher_type = PhabricatorObjectHasWatcherEdgeType::EDGECONST; $types = array(); - $types[] = $member_type; + $types[] = $material_type; if ($this->needWatchers) { $types[] = $watcher_type; } @@ -255,7 +255,7 @@ if ($any_edges) { $member_phids = $edge_query->getDestinationPHIDs( $source_phids, - array($member_type)); + array($material_type)); } else { $member_phids = array(); } @@ -488,7 +488,7 @@ $conn, 'JOIN %T e ON e.src = p.phid AND e.type = %d', PhabricatorEdgeConfig::TABLE_NAME_EDGE, - PhabricatorProjectProjectHasMemberEdgeType::EDGECONST); + PhabricatorProjectMaterializedMemberEdgeType::EDGECONST); } if ($this->slugs !== null) {