Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F17963927
D12785.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D12785.id.diff
View Options
diff --git a/src/applications/feed/story/PhabricatorFeedStory.php b/src/applications/feed/story/PhabricatorFeedStory.php
--- a/src/applications/feed/story/PhabricatorFeedStory.php
+++ b/src/applications/feed/story/PhabricatorFeedStory.php
@@ -453,15 +453,9 @@
* @task policy
*/
public function getPolicy($capability) {
- // If this story's primary object is a policy-aware object, use its policy
- // to control story visiblity.
-
- $primary_phid = $this->getPrimaryObjectPHID();
- if (isset($this->objects[$primary_phid])) {
- $object = $this->objects[$primary_phid];
- if ($object instanceof PhabricatorPolicyInterface) {
- return $object->getPolicy($capability);
- }
+ $policy_object = $this->getPrimaryPolicyObject();
+ if ($policy_object) {
+ return $policy_object->getPolicy($capability);
}
// TODO: Remove this once all objects are policy-aware. For now, keep
@@ -476,6 +470,11 @@
* @task policy
*/
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
+ $policy_object = $this->getPrimaryPolicyObject();
+ if ($policy_object) {
+ return $policy_object->hasAutomaticCapability($capability, $viewer);
+ }
+
return false;
}
@@ -484,6 +483,26 @@
}
+ /**
+ * Get the policy object this story is about, if such a policy object
+ * exists.
+ *
+ * @return PhabricatorPolicyInterface|null Policy object, if available.
+ * @task policy
+ */
+ private function getPrimaryPolicyObject() {
+ $primary_phid = $this->getPrimaryObjectPHID();
+ if (empty($this->objects[$primary_phid])) {
+ $object = $this->objects[$primary_phid];
+ if ($object instanceof PhabricatorPolicyInterface) {
+ return $object;
+ }
+ }
+
+ return null;
+ }
+
+
/* -( PhabricatorMarkupInterface Implementation )--------------------------- */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Aug 2, 10:53 AM (3 d, 14 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
8802534
Default Alt Text
D12785.id.diff (1 KB)
Attached To
Mode
D12785: Fix excessively-conservative feed story policy checks
Attached
Detach File
Event Timeline
Log In to Comment