Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15391250
D12788.id30741.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D12788.id30741.diff
View Options
diff --git a/src/applications/subscriptions/events/PhabricatorSubscriptionsUIEventListener.php b/src/applications/subscriptions/events/PhabricatorSubscriptionsUIEventListener.php
--- a/src/applications/subscriptions/events/PhabricatorSubscriptionsUIEventListener.php
+++ b/src/applications/subscriptions/events/PhabricatorSubscriptionsUIEventListener.php
@@ -21,6 +21,7 @@
private function handleActionEvent($event) {
$user = $event->getUser();
+ $user_phid = $user->getPHID();
$object = $event->getValue('object');
if (!$object || !$object->getPHID()) {
@@ -33,12 +34,12 @@
return;
}
- if (!$object->shouldAllowSubscription($user->getPHID())) {
+ if (!$object->shouldAllowSubscription($user_phid)) {
// This object doesn't allow the viewer to subscribe.
return;
}
- if ($object->isAutomaticallySubscribed($user->getPHID())) {
+ if ($user_phid && $object->isAutomaticallySubscribed($user_phid)) {
$sub_action = id(new PhabricatorActionView())
->setWorkflow(true)
->setDisabled(true)
@@ -50,15 +51,14 @@
$subscribed = false;
if ($user->isLoggedIn()) {
$src_phid = $object->getPHID();
- $dst_phid = $user->getPHID();
$edge_type = PhabricatorObjectHasSubscriberEdgeType::EDGECONST;
$edges = id(new PhabricatorEdgeQuery())
->withSourcePHIDs(array($src_phid))
->withEdgeTypes(array($edge_type))
- ->withDestinationPHIDs(array($user->getPHID()))
+ ->withDestinationPHIDs(array($user_phid))
->execute();
- $subscribed = isset($edges[$src_phid][$edge_type][$dst_phid]);
+ $subscribed = isset($edges[$src_phid][$edge_type][$user_phid]);
}
if ($subscribed) {
diff --git a/src/applications/subscriptions/interface/PhabricatorSubscribableInterface.php b/src/applications/subscriptions/interface/PhabricatorSubscribableInterface.php
--- a/src/applications/subscriptions/interface/PhabricatorSubscribableInterface.php
+++ b/src/applications/subscriptions/interface/PhabricatorSubscribableInterface.php
@@ -7,6 +7,8 @@
* to the object (for example, they are the author or in some other way
* irrevocably a subscriber). This will, e.g., cause the UI to render
* "Automatically Subscribed" instead of "Subscribe".
+ * Watch out for $phid being NULL for logged out users (it's also the owner ID
+ * of un-owned objects) before calling this.
*
* @param PHID PHID (presumably a user) to test for automatic subscription.
* @return bool True if the object/user is automatically subscribed.
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Mar 16, 9:02 AM (1 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7706699
Default Alt Text
D12788.id30741.diff (2 KB)
Attached To
Mode
D12788: Don't claim logged out users are automatically subscribed to un-owned objects
Attached
Detach File
Event Timeline
Log In to Comment